ValueContainer.tsx 678 B

123456789101112131415161718192021
  1. import React from 'react';
  2. import { components } from 'react-select';
  3. export const ValueContainer = props => {
  4. const { children, getValue, options } = props;
  5. console.log('getValue', getValue());
  6. console.log('options', options);
  7. const existingValue = getValue();
  8. const selectedOption = options.find(i => (existingValue[0] ? i.id === existingValue[0].id : undefined));
  9. console.log('selectedOption', selectedOption);
  10. return (
  11. <components.ValueContainer {...props}>
  12. {children}
  13. {/* {selectedOption ?
  14. <span>{selectedOption.label}</span>
  15. : children} */}
  16. </components.ValueContainer>
  17. );
  18. };
  19. export default ValueContainer;