DEV Community

Discussion on: How to: mobx-state-tree + react + typescript

Collapse
 
havef profile image
HaveF

Thanks for your detailed explanation!

useInject is a bit complicate to me, so I'm sticking to use useStore :-)

And another thing I found when I try your great example is enhanced the useStore with types:

export const useStore = () => useContext(StoreContext)

Enter fullscreen mode Exit fullscreen mode

to

export const useStore: () => TRootStoreModel = () => useContext(StoreContext) as TRootStoreModel

Enter fullscreen mode Exit fullscreen mode

Then it will be more convenience to use useStore with ts autocomplete feature!