Skip to content

Instantly share code, notes, and snippets.

@josegl
Last active January 28, 2016 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josegl/e2aa611089448897f50e to your computer and use it in GitHub Desktop.
Save josegl/e2aa611089448897f50e to your computer and use it in GitHub Desktop.
export default ({
value, update
}) => (¬
<div>
<input onChange={e => update(e.target.value) value={value}}/>
</div>¬
);
import React, { Component } from 'react';¬
import Input from './Input';¬
import { connect } from 'react-redux';¬
import { updateValue } from './actions';¬
const mapStateToProps = (state) => {¬
const { value} = state;¬
return {value };¬
}
const mapDispatchToProps = (dispatch) => {¬
return {¬
update: (value) => {¬
if (this.props.value !== value) //this is possible??? omg
dispatch(updateValue(value));¬
}¬
}¬
}¬
¬
export default connect(¬
mapStateToProps,¬
mapDispatchToProps¬
)(Input);¬
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment