This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Use the tracked hooks in React components, no providers needed. Select your
state and the component will trigger re-renders only if the accessed property is changed. Use the useTracked method:
// Global tracked hook selectors
export const useTrackedStore = () => mapValuesKey('useTracked', rootStore);
// with useTrackStore UserEmail Component will only re-render when accessed property owner.email changed
const UserEmail = () => {
const owner = useTrackedStore().repo.owner();
return (
<div>
<span>User Email: {owner.email}</span>
</div>
);
};
// with useStore UserEmail Component re-render when owner changed, but you can pass equalityFn to avoid it.
const UserEmail = () => {
const owner = useStore().repo.owner();
// const owner = useStore().repo.owner((prev, next) => prev.owner.email === next.owner.email)
return (
<div>
<span>User Email: {owner.email}</span>
</div>
);
};
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
@udecode/zustood@1.1.0
Minor Changes
#36
c66963c
Thanks @ShinyLeee! -react-tracked
supportUse the tracked hooks in React components, no providers needed. Select your state and the component will trigger re-renders only if the accessed property is changed. Use the
useTracked
method: