Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add is.renderInReact or is.notRenderInReact #168

Closed
tychenjiajun opened this issue Jun 9, 2022 · 1 comment
Closed

Add is.renderInReact or is.notRenderInReact #168

tychenjiajun opened this issue Jun 9, 2022 · 1 comment

Comments

@tychenjiajun
Copy link

https://reactjs.org/docs/jsx-in-depth.html#booleans-null-and-undefined-are-ignored

Only certain types in React can be rendered. false, null, undefined, and true are valid React children. They don’t render.

Here, I propose a new API and its use case:

<div>{is.renderInReact(foo) ? foo : EMPTY_VALUE}</div>

Since renderInReact might requires @types/react, notRenderInReact may be better. It's equal to the combination of nullOrUndefined and boolean.

The name may be changed to something simpler, like is.render

@sindresorhus
Copy link
Owner

What's the practical use-case of this? When would you just want to output any value that React can render and ignore any it cannot? I have done a lot of React work and I cannot say I ever encountered this use-case, some I'm very curious.

@sindresorhus sindresorhus closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants