Last active
November 19, 2016 17:04
-
-
Save git-toni/342f747b1d120cfc87b9db88d1d2c3c0 to your computer and use it in GitHub Desktop.
Mobx-React Provider test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React,{Component} from 'react' | |
import ReactDOM from 'react-dom' | |
import {observable} from 'mobx' | |
import {observer, Provider} from 'mobx-react'; | |
const store=observable({ | |
num:33, | |
name:'john' | |
}) | |
@observer // ALthough @observer(['store']) *does* work! | |
class MyComponent extends Component{ | |
render(){ | |
console.log('rendering', this.props)//< --- shouldnt it print the whole store observed object?ie { num:33, name:'john'} | |
return <h2>{this.props.store.toString()}</h2> | |
} | |
} | |
ReactDOM.render( | |
<Provider store={store}> | |
<MyComponent /> | |
</Provider>, | |
document.getElementById("app-container") | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment