Automatic observer on a React tree #3798
Unanswered
sarimarton
asked this question in
General
Replies: 2 comments 2 replies
-
I tried this and indeed it works as advertised with MobX - components would re-render without having to wrap them in Unfortunately, since I use NX with Webpack, Fast Refresh seems to break with this combination which is a deal breaker for me (and I'm sure many other). |
Beta Was this translation helpful? Give feedback.
2 replies
-
It looks pretty good. IMHP, adding HOC is very annoying and verbose. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I developed a library called react-beyond, which enables the application of a Higher-Order Component (HOC) not just to a single component, but recursively to all its descendant elements (and their descendants, and so on). This offers a significant ergonomic advantage in MobX, as it eliminates the need to wrap every component with observer. This requirement was a major deterrent for me in using MobX previously.
A demo is available on the landing page at https://react-beyond.github.io/#hoc. Here, you can see that the App component (and all its descendants in the tree) do not need individual wrapping, as they are under a
<Beyond features={[hoc(observer)]}>
component.I wanted to let you guys know about its existence. If you find it useful, perhaps you could mention it in the relevant sections of the MobX guide. And of course any feedback is welcome.
cheers
Beta Was this translation helpful? Give feedback.
All reactions