A simple "useReaction" useState-like hook? #3824
Answered
by
urugator
mckravchyk
asked this question in
General
-
Hey. I was wondering, is it possible to just do something like this? To get a hook for an observable value exactly like useState? const todoEntry = useReaction(() => store.todos.todos.get(id)); where store is a value in the context, i.e.: export function createStore() {
const todosSlice = {
todos: observable.map(),
order: [],
};
makeObservable(todosSlice, {
order: observable,
});
return {
todos: todosSlice,
};
};
const store = createStore(); I look at the mobx-react-lite README.md and it seems like the presented workflow is somewhat different. |
Beta Was this translation helpful? Give feedback.
Answered by
urugator
Jan 29, 2024
Replies: 1 comment 1 reply
Answer selected by
iChenLei
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#2566 (reply in thread)