dimanche 2 septembre 2018

Using props in a function which is not a component in react

So, say for example my code looks something like this:

class DoSomething extends Component{
  function1(var1, var2){
    return var1 * var2 / this.props.var3
  }

  render(){
    <div>{function1(10, 20)}</div>
  }
}

I would like to abstract function1 into its own file and import it but I would still like it to have access to this component's (or redux's) props / state.

What would be the best way of accomplishing this? Sorry if this question is really whishy, washy.

Aucun commentaire:

Enregistrer un commentaire