![]() And even if you would need that, you have hooks - they can be easily moved around and plugged into any component, which allows you to do these refactors easily - eg if you have some complex component logic that depends on state, you don't need to know where the state comes from - whether it's global/local/props - you just pass the state as params to hook.įorget about mobx and observables and think how you would solve this with react alone - you want to copy state of some parent component into a state of a child component - it's doable with useLayoutEffect/getDerivedStateFromProps/componentDidUpdate, but you will be always advised to lift the state up instead. ![]() ![]() ![]() You just make the application more complicated - it's very likely that the "synchronized" component will never be used standalone outside of your application, therefore there is no practical reason to keep it "decoupled" and introduce some additional abstraction to keep it in sync. You just want to move the coupling to some synchronization layer, but that itself won't remove the coupling. It won't, because the coupling already exists, otherwise you wouldn't need to synchronize. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |