No one wants to reinvent the wheel.
That's why it's so important to be able to use components that someone else had created and put on npm. In this lesson we are going to learn how to use third party React Select in a React Final Form form to create a searchable select form field.
I see that we just have {...input} {...props} being sent to the Select field, can we add some of the custom props from Select like formatOptionLabel or onChange?
@CXP you can pass any props to the Field
component and the {...rest}
option in ReactSelectAdapter
will apply it to the component for you:
<Field
name="library"
component={ReactSelectAdapter}
options={libraries}
onChange={() => console.log('nice')} // this will fire on ever onChange event
/>
We had issues using component={ReactSelectAdapter}
and then getting the react-select
field's new value linked up properly, so we ended up using react-final-form
's render
instead of component
.