qrbtf/src/containers/param/ParamTextViewer.js

22 lines
784 B
JavaScript
Raw Normal View History

2020-05-08 16:04:36 +00:00
import { connect } from 'react-redux';
import ParamText from "../../components/param/ParamText";
import {changeParam} from "../../actions";
const mapStateToProps = (state, ownProps) => ({
rendererIndex: ownProps.rendererIndex,
paramIndex: ownProps.paramIndex,
2020-05-10 10:15:02 +00:00
value: String(state.paramValue[ownProps.rendererIndex][ownProps.paramIndex])
2020-05-08 16:04:36 +00:00
})
const mapDispatchToProps = (dispatch, ownProps) => ({
onBlur: (e) => dispatch(changeParam(ownProps.rendererIndex, ownProps.paramIndex, e.target.value)),
onKeyPress: (e) => {
if(e.key === 'Enter') {
dispatch(changeParam(ownProps.rendererIndex, ownProps.paramIndex, e.target.value));
e.target.blur()
}
}
})
export default connect(mapStateToProps, mapDispatchToProps)(ParamText);