Closed OmarRhinoActive closed 4 years ago
When trying to update component state like this(where setVar is a set function returned from a call to useState):
useState
<SelectSearch options={users} search placeholder="Select User" onChange={setVar} />
The state is updated but the following React warning appears:
Warning: Cannot update a component from inside the function body of a different component.
This is a new warning as of React 16.13 and there's some documentation and potential solutions here: https://reactjs.org/blog/2020/02/26/react-v16.13.0.html
I also tried doing something like this: onChange={(value, option) => setVar(option.name)} but that gives the same warning.
onChange={(value, option) => setVar(option.name)}
@OmarRhinoActive This was fixed in v2.0.1
When trying to update component state like this(where setVar is a set function returned from a call to
useState
):The state is updated but the following React warning appears:
Warning: Cannot update a component from inside the function body of a different component.
This is a new warning as of React 16.13 and there's some documentation and potential solutions here: https://reactjs.org/blog/2020/02/26/react-v16.13.0.html
I also tried doing something like this:
onChange={(value, option) => setVar(option.name)}
but that gives the same warning.