JedWatson / JedWatson/react-select
Setting new state in loadOptions crashing the Control
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to set the searchString into a state, but after typinbg 2 letters, the control is crashing.
Keep in mind this issue was not happening when I did not replace any components.
const [searchString, setSearchString] = useState<string>('');
searchString: string
): Promise<ProductOption[]> => {
setSearchString(searchString);
const productsResponse = await handleSearch(searchString);
const options = productsResponse.data.map<ProductOption>((p) => ({
value: p.id,
label: p.name,
image: p.image,
}));
totalItems = productsResponse.totalItems;
return options;
};```
`const Control = ({
children,
...props
}: ControlProps<ProductOption, false>) => (
<components.Control {...props}>
<Search className='ms-2' /> {children}
</components.Control>
);
`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the crash with the shown findProducts and custom Control components, focusing on the state update after two typed letters. Inspect the resulting error and the loadOptions/custom-component interaction; done means setting searchString no longer crashes the control while searching.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100