concept Autocomplete component in category react

appears as: Autocomplete component, The Autocomplete component
React Quickly: Painless web apps with React, JSX, Redux, and GraphQL

This is an excerpt from Manning's book React Quickly: Painless web apps with React, JSX, Redux, and GraphQL.

20.5. Implementing the Autocomplete component

The Autocomplete component is self-sufficient, meaning it isn’t just a view component but can also fetch from and save to the REST API. It has two properties: options and url. In accordance with TDD, let’s start coding the Autocomplete component with tests.

20.5.2. The code for the Autocomplete component

Finally, it’s time to write the Autocomplete component (ch20/autocomplete/src/autocomplete.jsx). It includes the input field, the list of matching options, and the Add button to add a new option when there are no matches. The component performs two AJAX/XHR calls: to retrieve a list of options and to create a new option. There are two methods: