Recently, we decided to move from using React's context functionality directly, to using MobX's Provider feature. Updating the code was a little painful, but not nearly as hard as trying to move from React Router v2 to v4! There were a few things that were hard in particular, such as updating all of the Enzyme-based tests. If you need to do the same thing, here are some tips: First of all, start by reading all the documentation on Provider and inject . I'm not going to duplicate that here. Let's suppose you have a component named MyComponent, and you have a MobX store named myStore. If you're using a function-based component like: const MyComponent = inject('myStore')(observer(cssModules( ({ myStore }) => <div>hi!</div>, styles, ))); export default MyComponent; Then to set the propTypes, you'll need to write: MyComponent.wrappedComponent.propsTypes = { myStore: PropTypes.object.isRequired }; Thankfully, you'll get a w
This is a purely technical blog concerning topics such as Python, Ruby, Scala, Go, JavaScript, Linux, open source software, the Web, and lesser-known programming languages.
Ad maiorem Dei gloriam inque hominum salutem.