Created
April 7, 2021 22:55
-
-
Save aqrojo/562152e57d7bc682e6bfb10e32c245e6 to your computer and use it in GitHub Desktop.
mobx-introduction_04_observer
This file contains hidden or 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 { observable } from 'mobx' | |
import { observer } from 'mobx-react' | |
const store = observable({ | |
prop1: 1, | |
prop2: 2, | |
... | |
}) | |
function ComponentA () { | |
return ( | |
<span>El valor de prop1 {store.prop1}</span> | |
) | |
} | |
function ComponentB () { | |
return ( | |
<span>El valor de prop2 {store.prop2}</span> | |
) | |
} | |
// conectamos el componente | |
export observer(ComponentA) | |
export observer(ComponentB) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment