5 ms·
Would you elaborate on what you find clunky about the new context API? :)
by brianvaughn 8y ago
Would you elaborate on what you find clunky about the new context API? :)
- CuriouslyC 8y agoWell, I tend to make a lot of very small stateless components. If a component is 1-6 JSX tags, the new context API represents a boilerplate overhead of between 100 and ~17%. Additionally, the semantics of having a consumer's props.children be an immediately invoked function are a little bit unintuitive to me. I think having multiple ways to pass "props" increases the api surface area, having everything "just be props" would be simpler.
- brianvaughn 8y ago> Well, I tend to make a lot of very small stateless components. If a component is 1-6 JSX tags, the new context API represents a boilerplate overhead of between 100 and ~17%. Not if you use a HOC (e.g. `withContext(Component)`) like a couple of the docs examples showed. > Additionally, the semantics of having a consumer's props.children be an immediately invoked function are a little bit unintuitive to me. That's fair! I would encourage you to give it a chance though. I think it's a pattern that really grows on you after a short time. :)