Last active
January 28, 2016 12:01
-
-
Save josegl/e2aa611089448897f50e to your computer and use it in GitHub Desktop.
This file contains 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
export default ({ | |
value, update | |
}) => (¬ | |
<div> | |
<input onChange={e => update(e.target.value) value={value}}/> | |
</div>¬ | |
); |
This file contains 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 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