Set useState from useTrackedState in react-tracked

I am using 'react-tracked' library to maintain global state.

In a page, I have to show a filter box with list below. When user types something in filter, we would update the list accordingly.

Currently I have all my source data in the global state. But for this case, I want to use local state as the filter is just for this page. But when I try to assign, the local state is always empty. Not sure why.


import {createContainer} from 'react-tracked';
export const {Provider, useTracked: useSharedState} = createContainer(() =>
    useState({users:[{name:user1}, {name:user2}]}),


import {useSharedState} from './Store';
export const Users = () => {
    const [state, setState] = useSharedState();
    const [foundUsers, setFoundUsers] = useState(() => state.users);
    Console.log(state.users.length); // 2
    Console.log(foundUsers.length); // 0
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum