'Is it possible to tell a render prop appart from a ReactNode?
I am making a reusable component that currently accepts a ReactNode. However I would also like to have it accept a render prop function. However I think just checking if typeof propName === "function" to distinguish the two options would not work since a ReactNode might be a functional component. So my question is whether there is a property defined on functional components that would allow me to tell them appart from a regular function.
Solution 1:[1]
I was confused about the ReactNode. Looking at the definition it's actually never a function. So typeof propName === "function" should work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | kaan_a |
