ReactJS: How to wrap react-select in redux-form field?

后端 未结 5 1059
难免孤独
难免孤独 2021-02-13 02:57

I am working on react-select library and facing some issues, I am using redux-form library and importing component from it

5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-13 03:31

    Here this worked for me,

    import React, { Component } from 'react';
    import Select from 'react-select';
    import 'react-select/dist/react-select.css';
    
    export default class RenderSelectInput extends Component {
     onChange(event) {
      if (this.props.input.onChange && event != null) {
       this.props.input.onChange(event.value);
      } else {
       this.props.input.onChange(null);
      }
     }
    
     render() {
      const { input, options, name, id, ...custom } = this.props;
      return (
       
                            
        
    提交评论

提交回复
热议问题