Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Compared to React, what isn't available in Preact?


Last time I checked you couldn't use contexts yet.


Thats a good thing.

Context is not a good feature, and even the developers didn't want to write documentation for it because they didn't want people to use it. https://github.com/facebook/react/issues/580


As people adopt external state containers, like Flux and Redux, it becomes increasingly impractical to bucket brigade chunks of data and callbacks to the leaves of the component tree via props. Some sort of delivery mechanism that doesn't couple in intermediate components is pretty critical to avoid having to maintain an unbounded amount of glue code. Context isn't without its kinks, but it's pretty useful in cutting boilerplate and decoupling components. The one thing I don't buy is that it's somehow worse than props from an architectural perspective (it's often compared to global variables, which makes little sense to me).


Then how would something like react-redux work without context?


It can already work without contexts. You just pass a store instance via props.

I don't like contexts either :(


Yup. I've successfully added contexts to Preact, but I still am not 100% sold on the value. Thankfully, simply supporting them doesn't add much bloat.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: