0

I tried out the Autocomplete example from Material UI. Its about an add option when entering a new value. Here is the link to the demo: https://codesandbox.io/s/material-demo-forked-lgeju?file=/demo.js What I am wondering about is that the value in the input isnt actually added to the options in this example so it doesnt actually work. Why is that so? Also I cant use it for multiple select, (via adding the property "multiple" to the Autocomplete) since this would produce a "TypeError Cannot read property 'length' of null". Is there a way to make that work for multiple select?

Would appreciate any help a lot.

2 Answers 2

1

According to the documentation regarding multiple prop:

If true, value must be an array and the menu will support multiple selections.

So just initialize your state as an array so that it would have the property length and is an array so that satisfies the condition I quoted above

const [value, setValue] = React.useState([]);
Sign up to request clarification or add additional context in comments.

Comments

0

for add item top100Films.push(value)

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.