Creating a global store like redux

I'm attempting to create a store to keep track of user data across the application and so far this is what I have
const userStore = createStore({
username: null,
isLoading: true,
isLoggedIn: false
});

// similar to dispatch ( ? )
export const login = () => {
const [userState, setUserState] = userStore;
setUserState("isLoggedIn", true);
setUserState("isLoading", false);
}
const userStore = createStore({
username: null,
isLoading: true,
isLoggedIn: false
});

// similar to dispatch ( ? )
export const login = () => {
const [userState, setUserState] = userStore;
setUserState("isLoggedIn", true);
setUserState("isLoading", false);
}
I'm wondering if this is the right approach.
1 Reply
lxsmnsyc
lxsmnsyc2y ago
It's okay
Want results from more Discord servers?
Add your server