Closed serendipity1004 closed 4 years ago
If you search through issues here, you will find some solutions around typing inject correctly.
However, you might consider abandoning inject if you want to save yourself some soul health :)
See #256: You will have the make map optional, map?: MapStore
, and at non-null assertions inside your component if needed; {props.map!}
.
useContext
is an easier way to get type-safe injection in FC's, so we recommend to use that now.
@serendipity1004 I am sorry if my response sounded a bit harsh, that wasn't the intention. As the link states, there is nothing wrong about inject
and you can keep using it, but be prepared for some extra battles that can be solved more easily with Context.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.
I have a functional root component like below
and my map component is looking like below
I am expecting IMapProps to obviously come from the mobx injection; however, typescript is throwing error saying that I should provide the props in the root component. Error looks like below
How do I provide types for props that come from the mobx store?