Re:React v16.3.0: New lifecycles and context API
by brianvaughn on Friday March 30, 2018 @02:35PM
(#16718654)
Yes, but then that prop would need to be passed down explicitly through every component. This would require a _lot_ of boilerplate.
Re:React v16.3.0: New lifecycles and context API
by brlewis on Friday March 30, 2018 @03:38PM
(#16719153)
OK, it just boils down to me thinking one explicit prop for every component isn't too much boilerplate. I can see some teams liking the idea of shaving off that explicit prop as long as everybody knows about the implicit context(s) that also affect component behavior.
Re:React v16.3.0: New lifecycles and context API
by brianvaughn on Friday March 30, 2018 @04:15PM
(#16719461)
> s everybody knows about the implicit context(s) that also affect component behavior.
Just in case there's any misunderstanding- (I don't think there is, but just being safe)- context isn't implicit. You have to opt into it either by using the `<Consumer>` component or a HOC that injects a context prop.
I know there are several ways to construct a component, but I like that your examples make them functions of props, because that's how I picture a component. Having its behavior depend on a semi-hidden context appears less purely functional. To stretch the term a little, the component is no longer idempotent. Maybe there's a situation where that's what you want, but the examples you've given so far sound like ones where props would serve just fine.