Simon Høiberg
1 min readDec 1, 2018

--

That’s a good question, Danny Feliz

If you’re in a situation where you strictly HAVE to pass a parameter to the method from render, that would be a symptom of bad design.
In most cases, you can get around this.

If it’s the case that you’re instantiating a collection of components through iteration, and you want a method on each that needs a reference to it’s associated component, simply prop down the reference as you iterate, and pass the reference back up as a parameter when the method is called.

If, on the other hand, you need to do a reference to the execution context within which the render() method is defined, do the reference from the method that you’re calling since it’s defined within the same execution context as render(). No need for passing anything as a parameter.

I hope it makes sense 😊

--

--

Simon Høiberg
Simon Høiberg

No responses yet