Using MobX in a SPFx 1.7.x project

%3CLINGO-SUB%20id%3D%22lingo-sub-323677%22%20slang%3D%22en-US%22%3EUsing%20MobX%20in%20a%20SPFx%201.7.x%20project%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-323677%22%20slang%3D%22en-US%22%3E%3CP%3EHas%20somebody%20successfully%20used%20MobX%20(especially%20with%20the%20React%20bindings)%20in%20a%20nontrivial%20SPFx%201.7.x%20project%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20developing%20a%20webpart%20with%20several%20React%20components%26nbsp%3Bwhere%20MobX%20will%20be%20used%20as%20a%20central%20state%20manager.%20Up%20to%20now%20I've%20experienced%20the%20following%20problems%3A%3C%2FP%3E%3CUL%3E%3CLI%3EI%20can%20only%20use%20mobx-react%20version%205.2.8%20or%20less%20because%20in%20more%20recent%20versions%20there%20is%20TypeScript%20code%20that%20the%20TypeScript%20compiler%20installed%20with%20SPFx%20(version%202.4.2)%20cannot%20handle%3B%3C%2FLI%3E%3CLI%3EUsage%20of%20the%20Provider%20component%20in%20mobx-react%20as%20a%20JSX%20tag%20results%20in%26nbsp%3Ba%20strange%20TypeScript%20error.%20The%20workaround%20I've%20found%20is%20to%20use%20React.createElement%20but%20this%20looks%20(and%20feels)%20weired.%3C%2FLI%3E%3C%2FUL%3E%3CP%3EThis%20is%20only%20the%20start%20of%20the%20project%20and%20I'm%20wondering%20what%20else%20will%20pop%20up.%20So%20I'm%20curious%20if%20somebody%20has%20successfully%20used%20it%20and%20maybe%20has%20tips%20or%20pointers.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Has somebody successfully used MobX (especially with the React bindings) in a nontrivial SPFx 1.7.x project?

 

I'm developing a webpart with several React components where MobX will be used as a central state manager. Up to now I've experienced the following problems:

  • I can only use mobx-react version 5.2.8 or less because in more recent versions there is TypeScript code that the TypeScript compiler installed with SPFx (version 2.4.2) cannot handle;
  • Usage of the Provider component in mobx-react as a JSX tag results in a strange TypeScript error. The workaround I've found is to use React.createElement but this looks (and feels) weired.

This is only the start of the project and I'm wondering what else will pop up. So I'm curious if somebody has successfully used it and maybe has tips or pointers.

0 Replies