reactjs mobx without decorators not working -
i trying incorporate mobx
react
. since spawned application using create-react-app
, can't use decorators given mobx.
given can use mobx without decorators per documentation: https://mobxjs.github.io/mobx/best/decorators.html
here's component created:
import react, { component } 'react'; import observer 'mobx-react'; export const testcomponent = observer(class testcomponent extends component { render() { return <div>just test component!</div> } });
here's simple calling of above component:
import react, { component } 'react'; import './app.css'; import auth './auth' import { testcomponent } './test' import muithemeprovider 'material-ui/styles/muithemeprovider'; import appbar 'material-ui/appbar'; import authstore './stores/store' class app extends component { constructor(props) { super(props); this.state = { } } render() { return ( <div classname="app"> <muithemeprovider> <div> <testcomponent store={authstore} /> </div> </muithemeprovider> </div> ); } } export default app;
now when run above component, error: uncaught typeerror: (0 , _mobxreact2.default) not function(…)
nothing displays in console.
what doing wrong here?
please use import {observer} 'mobx-react';
n.b. note decorators can used create-react-app using custom-react-scripts, explained here)
Comments
Post a Comment