JedWatson / JedWatson/react-select
Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
I have experienced an issue with 'react-select' library when displaying translated options inside the dropdown. I am getting the attached screenshot error
Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
The error occurs randomly on several pages and it is hard to reproduce this error but it seems to be coming from the react-select library when it is configured to use the translation options. Example:
const dateRangeList = [
{ label: getText('retailtransactions:DATERANGE_TODAY'), value: TODAY },
{ label: getText('retailtransactions:DATERANGE_YESTERDAY'), value: YESTERDAY },
{ label: getText('retailtransactions:DATERANGE_THIS_WEEK'), value: THIS_WEEK },
{ label: getText('retailtransactions:DATERANGE_LAST_WEEK'), value: LAST_WEEK },
{ label: getText('retailtransactions:DATERANGE_THIS_MONTH'), value: THIS_MONTH },
{ label: getText('retailtransactions:DATERANGE_LAST_MONTH'), value: LAST_MONTH },
];
I am configuring the above code to populate the react-select options and then I am calling the following code in jsx file
<Select name="dateRange" className="date-range rdt mt-30" placeholder={getText('retailtransactions:DATERANGE')} value={state.dateRange ? dateRangeList.filter((date) => date.value === state.dateRange)[0] : ''} onChange={(val) => onDateRangeChange(val)} options={dateRangeList} />
Here I am using an helper function getText which pull the value from the react-i18next translation file
import { ENGLISH_LANG } from 'configs/constants';
import i18n from '../../i18n';
export const getText = (label) => {
if (i18n.t && (!i18n.t(label) || i18n.t(label)?.length === 0)) {
return i18n.t(label, { lng: ENGLISH_LANG });
} else if(i18n.t) {
return i18n.t(label);
} else {
return label;
}
};
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 with the JSX usage, the dateRangeList construction, and the getText helper shown in the issue; reproduce the intermittent error with translated options. Inspect the react-select DOM removal behavior, and consider the issue done when the reported removeChild error no longer occurs during translated option updates.
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
- 28/100