如何使用es6 onchange获取所选值

时间:2017-05-08 10:04:48

标签: reactjs redux

我正在使用semantic-ui's react dropdown。我似乎无法在我的函数中获取所选值(使用redux)。

设置:

模块:

const types = [ { value: 'Rails', text: 'Rails' }, ... ]

const DropdownMenu = (props) => (
  <Dropdown placeholder='Select...' fluid selection options={types} onChange={(e) => props.backendSelect(e)} />
)

动作:

export const backendSelect = (text) => ({
  type: BACKEND_TYPE_SELECT,
  text,
})

减速机:

const backendTypeSelect = (state = '', action) => {
  console.log(action)
  switch (action.type) {
    case BACKEND_TYPE_SELECT:
      return action.text;
    default:
      return state;
  }
};

我的功能是否正确:onChange={(e) => props.backendSelect(e)}

const mapStateToProps = (state) => ({ backendTypeSelect: state.backendTypeSelect })

export default connect(mapStateToProps, actions)(<APP>);

1 个答案:

答案 0 :(得分:0)

尝试从事件中提取值,如下所示:

SparkConf conf = new SparkConf()
.setMaster("spark://SPARK-MASTER-ADDRESS:7077")
.setJars(new String[]{"build\\libs\\spark-test-1.0-SNAPSHOT.jar"})
.setAppName("APP-NAME");