---
title: "Functions are not valid as a React child"
description: "React shows this warning when JSX contains a function instead of an element. Learn the usual causes, such as a missing call or angle brackets, and how to fix each one."
url: https://www.danny.engineering/answer/react/functions-are-not-valid-as-a-react-child
author: Danny
published: 2026-11-27T00:00:00.000Z
updated: 2026-11-27T18:57:00.000Z
tags: ["React"]
---

# Functions are not valid as a React child

## The short answer


Somewhere in your JSX you are putting a function where React expects something it can render. Usually you wrote a component name without angle brackets, or forgot to call a helper function. Render the component as an element, or call the function.


```diff
function App() {
-  return <main>{Header}</main>;
+  return <main><Header /></main>;
 }
```


## Why it happens


React can render strings, numbers, elements, arrays of those, and `null`, `undefined` or booleans (which render nothing). A function is none of these. A component is a function too, but React only runs it when you write it as JSX, because JSX creates an element that tells React "call this component with these props".


When a function ends up as a child, React cannot know whether you meant to call it, render it or ignore it, so it warns and renders nothing. The full message gives you the two most likely reasons: "This may happen if you return a Component instead of `<Component />` from render. Or maybe you meant to call this function rather than return it."


Typical causes are:

- Writing `{Header}` instead of `<Header />`.
- Writing `{renderItems}` instead of `{renderItems()}`.
- Returning a component from a function, such as `return Spinner` instead of `return <Spinner />`.
- A render prop component that expects a function child, but the code calls it with the wrong prop name, or the reverse.
- A prop called `icon` or `component` that receives `Icon`, which the child then drops straight into JSX.

## How to fix it


### Render components as JSX


If the value is a component, wrap it in angle brackets so React creates an element.


```typescript
const pages = { home: HomePage, settings: SettingsPage };

function Router({ page }: { page: keyof typeof pages }) {
  const Page = pages[page];
  return <Page />;
}
```


The variable must start with a capital letter. JSX treats lower-case names as HTML tags, so `<page />` would render an unknown element called `page`.


### Call helper functions


If the value is a helper that returns JSX, call it.


```typescript
function List({ items }: { items: string[] }) {
  const renderItems = () => items.map((item) => <li key={item}>{item}</li>);

  return <ul>{renderItems()}</ul>;
}
```


Often it is cleaner to compute the value in a variable, or move it into its own component.


### Decide what a component prop should hold


When you pass a component through props, be clear whether the prop holds the component or an element. Both are fine; just render each correctly.


```typescript
// Prop holds the component itself
function Button({ icon: Icon, children }: { icon: React.ComponentType; children: React.ReactNode }) {
  return <button><Icon /> {children}</button>;
}
<Button icon={SaveIcon}>Save</Button>;

// Prop holds an element
function Card({ action, children }: { action: React.ReactNode; children: React.ReactNode }) {
  return <div>{children}{action}</div>;
}
<Card action={<SaveIcon />}>Saved</Card>;
```


Typing the prop as `React.ReactNode` makes TypeScript reject a bare function, which catches the mistake early.


### Call render props with their arguments


A component that accepts a function as `children` must call it.


```typescript
function MouseTracker({ children }: { children: (pos: Point) => React.ReactNode }) {
  const pos = useMousePosition();
  return <>{children(pos)}</>;
}
```


## Common pitfalls

- **Calling a component as a function to fix it.** `{Header()}` removes the warning but runs the component's hooks inside the parent, which can break the rules of hooks. Use `<Header />`.
- **Async functions in client components.** Passing an `async` function where JSX is expected is the same mistake. Only Server Components may be `async`.
- **Mixing up an event handler and its result.** `{onClick}` placed in the children of a button, rather than in its `onClick` prop, triggers this warning.
- **Objects are a different error.** If you see "Objects are not valid as a React child", you are rendering a plain object or a promise, not a function.

## Related reading

- [React: Your first component](https://react.dev/learn/your-first-component)
- [React: Passing props to a component](https://react.dev/learn/passing-props-to-a-component)
