Using MobX #417
Answered
by
will-stone
will-stone
asked this question in
Q&A
Using MobX
#417
|
Hi. Currently making a terminal game and Ink has been great fun for this. I'm jumping around a few state management solutions, seeing which feels the best. I'm currently at MobX and whilst it's great at separating the game engine from the view, it doesn't seem to play nice with Ink due to an apparent hard dependency on Has anyone had any luck with matching-up |
Answered by
will-stone
Feb 21, 2021
Replies: 1 comment
|
Okay, I think I've found the solution by importing and typing the // Doesn't work and throws an error about missing `react-dom` module
import { observer } from 'mobx-react-lite'Do this: import { observer as distObserver } from 'mobx-react-lite/dist/observer'
// @ts-expect-error workaround as mobx-react is expecting react-dom
import { observer as libraryObserver } from 'mobx-react-lite/lib/observer'
type Observer = typeof distObserver
export const observer: Observer = libraryObserverYou can then wrap components in const App: React.FC<{ game: Game }> = observer(({ game }) => {
...
}) |
0 replies
Answer selected by
will-stone
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Okay, I think I've found the solution by importing and typing the
observerfunction manually. So instead of this:Do this:
You can then wrap components in
observeras normal.