Commit f2989c57 authored by Ricardo Pierre-Louis's avatar Ricardo Pierre-Louis Committed by Tim Neutkens

Examples/with reflux (#3476)

* Update withData.js (#3458)

#3234

* Begun with-reflux example

* Built with-reflux example

* Built with-reflux example
parent 5bb710a0
import Reflux from 'reflux'
var Actions = Reflux.createActions([
'increment',
'decrement'
])
export default Actions
{
"name": "with-reflux",
"version": "1.0.0",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "latest",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"reflux": "^6.4.1"
},
"license": "ISC"
}
import React from 'react'
import Reflux from 'reflux'
import CounterStore from '../store/counterStore'
import Actions from '../actions/actions'
export default class Home extends Reflux.Component {
constructor () {
super()
this.store = CounterStore
}
render () {
return (
<div>
<h1>Counter Value: {this.state.counter}</h1>
<button onClick={Actions.increment}>Increment</button>
<button onClick={Actions.decrement}>Decrement</button>
</div>
)
}
}
import Reflux from 'reflux'
import Actions from '../actions/actions'
export default class StatusStore extends Reflux.Store {
constructor () {
super()
this.state = {counter: 0}
this.listenTo(Actions.increment, this.onIncrement)
this.listenTo(Actions.decrement, this.onDecrement)
}
onIncrement () {
this.setState({counter: this.state.counter + 1})
}
onDecrement () {
this.setState({counter: this.state.counter - 1})
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment