I am trying to learn Redux and I am curious to know what I am doing wrong here. I have a simple input field, and I want to dispatch an action to make the text uppercase whenever a change occurs in the input field. Here is my Redux store:
const TOCASE = (state="meow", action) => {
switch(action.type){
case 'UPPER':
return state.toUpperCase()
case 'LOWER':
return state.toLowerCase()
default:
return state
}
}
const {createStore} = Redux;
const store = createStore(TOCASE)
Here is my component:
const Case = React.createClass({
render(){
return(
<div>
{this.props.text}
<input type="text" value={this.props.text} onChange={this.props.onUpper}/>
</div>
)
}
})
const render = () => ReactDOM.render(<Case
text={store.getState()}
onUpper={(e)=>store.dispatch(e.target.value,{type: 'UPPER'})}
/>, document.getElementById('app'))
render()
store.subscribe(render)