Closed hardfist closed 4 years ago
Pretty much the same way. It might be useful you show what you have tried and did not work for you.
@FredyC Thanks! I figure it out, There's nothing to do with useLocalStore, useState works fine for me, The reason I failed because I forget to wrap Todo Component with observer, which doesn't rerender event todo is changed . The demo is here https://github.com/hardfist/hooks-puzzle/blob/master/src/store/todo.store.ts
I have another question, what's the difference between The following code when TodoStore is observable already https://github.com/hardfist/hooks-puzzle/blob/master/src/components/todo-mobx-local/index.tsx
const store = useLocalStore(() => new TodoStore());
const [store] = useState(() => new TodoStore());
Nothing 😊 and useState will do just fine
Op za 16 nov. 2019 14:27 schreef hardfist notifications@github.com:
I have another question, what's the difference between The following code when TodoStore is observable already https://github.com/hardfist/hooks-puzzle/blob/master/src/components/todo-mobx-local/index.tsx
const store = useLocalStore(() => new TodoStore()); const [store] = useState(() => new TodoStore());
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mobxjs/mobx-react-lite/issues/241?email_source=notifications&email_token=AAN4NBBTGRB4GCQ2VKC436LQT77LRA5CNFSM4JOEONNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEHSWLA#issuecomment-554642220, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBA5Z356422DIQF5X73QT77LRANCNFSM4JOEONNA .
It's very convenient do observable references to other observable, just like the following
how to implement this in useLocalStore