Answer the question
In order to leave comments, you need to log in
What is the correct way to use typescript(interfaces) with MobX?
There are 2 components, parent and child.
The child is connected to the mobx store.
interface IProps {
exercisesStore: {
isExercisesLoading: boolean;
exercises: IExercise[];
addExercise: (exercise: IExercise) => void;
updateExercise: (exercise: IExercise) => void;
};
}
const ChildComponent: FC<IProps> = inject('exercisesStore')(
observer(({ exercisesStore }) => {
// ...
}));
export default ChildComponent;
const ParentComponent: FC = ( ) => {
// ...
<ChildComponent />
}
export default ParentComponent;
Answer the question
In order to leave comments, you need to log in
The issue is resolved, one of the workarounds should be written like this:
exercisesStore?: {
...
};
... exercisesStore!.exercises ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question