Is there a better/cleaner way to do this ? #134
Replies: 1 comment
-
To make a component reactive to an observable's changes you can use You only need to call FutureWe're currently experimenting with a new feature to add a function Component () {
const test = useObservable(0)
const value = test.use()
...
} Or using it within the JSX like in your example would look like: function Component () {
const test = useObservable(0)
return (<>
{test.use() > 10 && <div>OMG MORE THAN 10!</div>}
</>)
} |
Beta Was this translation helpful? Give feedback.
-
Hello,
I recently discovered this library, and I have a question about a readability issue that I'm facing.
Firstly, is it necessary to use "enableLegendStateReact();" or "observer" in every component?
Secondly, can we use conditions in the template with useObservable without having to use useSelector? Because that forces me to declare a second constant. I'm also trying to avoid using observer to wrap my entire function as I find it greatly affects readability.
Thank you for the work you've done on this library!
Code example:
https://codesandbox.io/s/legend-state-tree-forked-yft2k6?file=/src/App.tsx
Beta Was this translation helpful? Give feedback.
All reactions