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

One thing I can’t figure out in hooks vs recompose is how to use them and avoid props drilling or even just basic wiring. One of the most glorious things about recompose is that the props are drilled/wired for you automatically. This turns out to be huge for me. I had so much tedious props drilling code that just went away with recompose. Anyone have any insight?


Use the Context API introduced in 16.3: https://reactjs.org/docs/context.html

This is the same API that or anything that "teleports" state around your tree uses internally.


Fun approach! But I don’t think that’s it? Just not the same kind of zero-effort awesomeness right? Also uses the context API for something it’s not intended for.


I'm not sure what you mean — the context API is specifically for moving data around the component tree without prop drilling. What are you talking about with regard to recompose?


I guess I just mean wiring. Recompose eliminates the need to do any wiring at all. You compose up your component, and then you have access to all those props without having wired them! The last thing I want to do is get the context API involved.




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

Search: