useStateXGetter()

Returns a getter function for reading the value of StateX state.

(pathOrAtom: PathOrStateXOrSelector<T>, options?: Options) => T;

Use this hook when a component intends to just read the state without subscribing to it. If a component used the useStateX() hook to get the setter, it would also subscribe to updates and re-render when the state changes. Using useStateXGetter() allows a component to read the value without re-rendering when the value changes.

Example