Our client was built in vanilla javascript, and therefore its state is not able to trigger React rerenders out of the box upon mutation. But fear not, for we have a simple, lightweight solution to this problem: the react-hooks package. It provides you with theDocumentation Index
Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
Use this file to discover all available pages before exploring further.
useReactiveClient hook, which wraps the client in a proxy that is ready to be used
directly inside JSX.
Since our client was built with a modular approach, this package comes as a
standalone, so to reduce the client’s package size.
Installation
Simply run the following in your terminal:- expo
- npm
- yarn
Shell
Using client’s state inside JSX
All you need to do is wrap your client withuseReactiveClient inside your component.
This wraps the client in a proxy that keeps track of, for each render, which variables you have accessed. As soon as one of these variables’ state mutates, React automatically rerenders, and the cycle restarts. This means you only trigger rerenders for variables you are actually reading from, keeping rerenders to a minimum.