When to use JSX.Element vs ReactNode vs ReactElement?
@lebyy▲ 0 net votes
Problem: I am currently migrating a React application to TypeScript. So far, this works pretty well, but I have a problem with the return types of my render functions, specifically in my functional components. I have always used JSX.Element as the return type, now… Fix (from the top answer): What is the difference between JSX.Element , ReactNode , and ReactElement ? A ReactElement is an object with type , props , and key properties: interface ReactElement< P = any, T extends | string | JSXElementConstructor<any> = string | JSXElementConstruct A JSX.Element is a ReactElement<any, any> . It exists as…