How to Fix the ‘Warning: Unknown DOM property class. Did you mean className?’ Error When Developing a React App?

Sometimes, we may run into the ‘Warning: Unknown DOM property class. Did you mean className?’ error when developing a React app.

In this article, we’ll look at how to fix the ‘Warning: Unknown DOM property class. Did you mean className?’ error when developing a React app.

Fix the ‘Warning: Unknown DOM property class. Did you mean className?’ Error When Developing a React App

To fix the ‘Warning: Unknown DOM property class. Did you mean className?’ error when developing a React app, we should make sure we replace the class attribute in our components with className.

For instance, we write:

import React from "react";

export default function App() {
  return <div className="hello">hello world</div>;
}

to assign the hello class to the div instead of:

import React from "react";

export default function App() {
  return <div class="hello">hello world</div>;
}

Conclusion

To fix the ‘Warning: Unknown DOM property class. Did you mean className?’ error when developing a React app, we should make sure we replace the class attribute in our components with className.