Skip to content

Instantly share code, notes, and snippets.

View octaviogb's full-sized avatar

Octavio Turra octaviogb

  • Guia Bolso
View GitHub Profile
@octaviogb
octaviogb / 3-global-state-snippets.md
Last active July 29, 2016 14:35 — forked from octavioturra/3-global-state-snippets.md
presentation about global state and 3 UI solutions

STATEFUL COMPONENT

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = { value: 0 };
  }
  incrementValue() {
    this.setState({
      value: this.state.value + 1
class Fetch {
create(store : object) {
if(!window.__fetch) {
window.__fetch = new Fetch()
}
Object.defineProperty(window.__fetch, 'state', {
get() {
return store.getState().login
}
});