How does React work with jquery-ui?

How does React work with jquery-ui?

Hi. Everyone, I wanna make my select options can be draggable recently but failed. Why???
The first method:
1. I downloaded the jquery-ui@1.12.1 package from jqueryui.com site. Extracted.
2. Copy jquery.js into my src folder. And import resources in my jsx code : import './jquery.js'. It goes smoothly.
But In another method, It goes wrong:
1. Use npm tool to install jquery-ui@1.12.1: npm install jquery-ui@1.12.1
2. import it: import 'jquery-ui' or import 'jquery-ui/build/release.js'. It throws the error! 










And here is my Code:
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import Select, { Creatable } from 'react-select';
  4. import 'react-select/dist/react-select.css';
  5. import $ from "jquery";
  6. import "jquery-ui/build/release.js";

  7. const propTypes = {
  8.   choices: PropTypes.array,
  9.   clearable: PropTypes.bool,
  10.   description: PropTypes.string,
  11.   freeForm: PropTypes.bool,
  12.   isLoading: PropTypes.bool,
  13.   label: PropTypes.string,
  14.   multi: PropTypes.bool,
  15.   name: PropTypes.string.isRequired,
  16.   onChange: PropTypes.func,
  17.   value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
  18.   showHeader: PropTypes.bool,
  19. };

  20. const defaultProps = {
  21.   choices: [],
  22.   clearable: true,
  23.   description: null,
  24.   freeForm: false,
  25.   isLoading: false,
  26.   label: null,
  27.   multi: false,
  28.   onChange: () => {},
  29.   showHeader: true,
  30. };

  31. export default class MulSelect extends React.Component{
  32.   constructor(props) {
  33.     super(props);
  34.     this.state = { options: this.getOptions(props) };
  35.     this.onChange = this.onChange.bind(this);
  36.   }
  37.   componentWillReceiveProps(nextProps) {
  38.     if (nextProps.choices !== this.props.choices) {
  39.       const options = this.getOptions(nextProps);
  40.       this.setState({ options });
  41.     }
  42.   }
  43.   onChange(opt) {
  44.     let optionValue = opt ? opt.value : null;
  45.     // if multi, return options values as an array
  46.     if (this.props.multi) {
  47.       optionValue = opt ? opt.map(o => o.value) : null;
  48.     }
  49.     this.props.onChange(optionValue);
  50.   }
  51.   getOptions(props) {
  52.     // Accepts different formats of input
  53.     const options = props.choices.map((c) => {
  54.       let option;
  55.       if (Array.isArray(c)) {
  56.         const label = c.length > 1 ? c[1] : c[0];
  57.         option = {
  58.           value: c[0],
  59.           label,
  60.         };
  61.       } else if (Object.is(c)) {
  62.         option = c;
  63.       } else {
  64.         option = {
  65.           value: c,
  66.           label: c,
  67.         };
  68.       }
  69.       return option;
  70.     });
  71.     if (props.freeForm) {
  72.       // For FreeFormSelect, insert value into options if not exist
  73.       const values = options.map(c => c.value);
  74.       if (props.value) {
  75.         let valuesToAdd = props.value;
  76.         if (!Array.isArray(valuesToAdd)) {
  77.           valuesToAdd = [valuesToAdd];
  78.         }
  79.         valuesToAdd.forEach((v) => {
  80.           if (values.indexOf(v) < 0) {
  81.             options.push({ value: v, label: v });
  82.           }
  83.         });
  84.       }
  85.     }
  86.     return options;
  87.   }

  88.   componentDidMount(props){
  89.     $("#react-select-2--value").sortable({
  90.       stop: (event, ui)=>{
  91.         //拖拽完成,同步hidden的input框
  92.         var inputs = $("#react-select-2--container").children("input");
  93.         var father = $("#react-select-2--value");
  94.         var childs = father.find(".Select-value").children(".Select-value-label").clone();
  95.         childs.find(':nth-child(n)').remove();
  96.         var val = [];
  97.         for(let i =0;i<childs.length;i++){
  98.           val.push(childs[i].innerText);
  99.           inputs[i].value = childs[i].innerText;
  100.         }
  101.         this.props.onChange(val);
  102.       }
  103.     });
  104.   }

  105.   render() {
  106.     //  Tab, comma or Enter will trigger a new option created for FreeFormSelect
  107.     const selectProps = {
  108.       multi: this.props.multi,
  109.       name: `select-${this.props.name}`,
  110.       placeholder: `Select (${this.state.options.length})`,
  111.       options: this.state.options,
  112.       value: this.props.value,
  113.       autosize: false,
  114.       clearable: this.props.clearable,
  115.       isLoading: this.props.isLoading,
  116.       onChange: this.onChange,
  117.       optionRenderer: opt => opt.label,
  118.     };
  119.     //  Tab, comma or Enter will trigger a new option created for FreeFormSelect
  120.     const selectWrap = this.props.freeForm ?
  121.       (<Creatable {...selectProps} />) : (<Select {...selectProps} />);
  122.     return (
  123.       <div>
  124.         <form action="when" method="GET">
  125.           {selectWrap}
  126.           <input type="submit" />
  127.         </form>
  128.       </div>
  129.     );
  130.   }
  131. }

  132. MulSelect.propTypes = propTypes;
  133. MulSelect.defaultProps = defaultProps;