The TypeScript error:

Type ‘X’ is not assignable to type ‘ReactNode’.

means that you’re trying to render a value in a React component that is not a valid React child. ReactNode is a type that includes anything that can be rendered: JSX elements, strings, numbers, null, undefined, booleans, etc.

Common Causes and Fixes

1. Returning a non-React value (e.g., an object or array of incorrect type)

❌ Example:
const myObj = { name: 'Prem' };
return myObj; // ❌ Error: object is not a valid ReactNode

Fix:
return

{myObj.name}

;

2. Passing a function or other type where JSX is expected

❌ Example:
const MyComponent = () => {
return () =>

Hello

; // ❌ returning a function
}

Fix:
const MyComponent = () => {
return

Hello

;
}

3. Rendering an array with invalid children

❌ Example:
const items = [{ id: 1 }, { id: 2 }];
return <>{items}; // ❌ Object is not a ReactNode

Fix:
return (
<>
{items.map(item =>

{item.id}

)}

);

4. TypeScript Type Mismatch in Props

If you’re passing props and TypeScript expects ReactNode but receives something else:
type MyProps = {
children: ReactNode;
}
const MyComponent = ({ children }: MyProps) =>

{children}

;

Ensure you pass valid children:

âś… Correct Usage:

Hello

Tip

If you’re unsure what X is in the error Type ‘X’ is not assignable to type ‘ReactNode’, hover over X in your IDE or use console.log(typeof X) to inspect it.

Need Help With Node Development?

Work with our skilled Node developers to accelerate your project and boost its performance.

Hire Node.js Developers

Support On Demand!

Related Q&A