Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Next.js and React

A React class component crashes with render is not a function

Your error

TypeError: instance.render is not a function2 more lines it can show

Fix it fast

Most common cause, 1 of 2

The class has no render method, or it is spelled differently

Add a render method that returns the JSX, spelled exactly render.

Fix
class Profile extends Component {
  render() {
    return <h1>{this.props.name}</h1>;
  }
}

// or, as React recommends for new code
function Profile({ name }) {
  return <h1>{name}</h1>;
}
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

TypeError: instance.render is not a function means React 19 built a class component instance and found no render method on it. Either render is missing or misspelled, or the constructor returned another object. The development console warning No render method found names the component and which case it is. Add render() or convert the class to a function component.

  • Applies to React 19.3
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Run the app in development mode and read the console warning that comes before the TypeError. It names the component, and its second half tells you which of the two causes below you have.

Run this first
npm run dev

Then find the line you see in this list and open its fix:

  1. 1The class has no render method, or it is spelled differentlyThe warning ends with you may have forgotten to define `render`.
  2. 2The constructor returns an objectThe warning ends with did you accidentally return an object from the constructor?

What does the error look like?

  • TypeError: instance.render is not a function
  • No `render` method found on the Profile instance: you may have forgotten to define `render`.
  • No `render` method found on the Profile instance: did you accidentally return an object from the constructor?

Cause 1 of 2

The class has no render method, or it is spelled differently

You seeThe warning ends with you may have forgotten to define `render`.

Check

instance.render is not a function with the forgotten-render warning means the class itself has no method called render. React prints this text when neither the instance nor the class prototype has a function called render. The React docs call render the one method a class component must have, so a class that only defines Render, renderContent or a lifecycle method fails here.

Check
grep -n -E "extends (React\.)?(Pure)?Component|render[[:space:]]*\(" src/components/Profile.jsx

Fix

Add a render method that returns the JSX, spelled exactly render. For new code React recommends a function component, which has no render method at all.

Fix
class Profile extends Component {
  render() {
    return <h1>{this.props.name}</h1>;
  }
}

// or, as React recommends for new code
function Profile({ name }) {
  return <h1>{name}</h1>;
}

Verify

Reload the page. The warning and the TypeError are both gone, and the component draws.

Verify
npm run dev

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 2

The constructor returns an object

You seeThe warning ends with did you accidentally return an object from the constructor?

Check

instance.render is not a function with the constructor warning means the constructor handed back an object in place of the instance. React shows this second wording when the class prototype does have render but the instance it got back does not. MDN notes that a derived class constructor may return an object; React's wording points at exactly that case, where the returned object stands in for the instance and carries no render.

Check
grep -n -A12 "constructor(props)" src/components/Profile.jsx

Fix

Remove the return from the constructor. The docs limit a constructor to calling super(props), setting this.state and binding methods.

Fix
constructor(props) {
  super(props);
  this.state = { open: false };
  // no return statement here
}

Verify

After a reload the console stays quiet, and toggling the open flag still updates the screen.

Verify
npm run dev

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • Write new components as functions, as the React docs recommend; only class components can hit this error.
  • Keep constructors to super(props), this.state and method binding, with no return.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: TaxiDex, QistLock, Taskvare.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.