react-component / react-component/portal
[BUG] Rendering in non browser environment (JSDOM)
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 26
- PR merge metrics
- No merged PRs in 30d
Description
When I am using portal component in a non browser environment, element in here is null:
const [ele] = React.useState(() => {
if (!canUseDom()) {
return null;
}
And then this code fails because ele is null:
function cleanup() {
ele.parentElement?.removeChild(ele);
appendedRef.current = false;
}
Contributor guide
No contributing guide indexed for this repository
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 locating the portal component and the cleanup function shown in the issue, then reproduce portal usage in the JSDOM environment. Check the non-browser path where ele is null and add or update coverage for cleanup; done means portal cleanup no longer fails when no DOM element was created.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100