Coding⏱️ 2 min read📅 2026-05-30

How to Fix: Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function but got: object

Invalid React component type error.

Quick Answer: Check the component tree for invalid elements, ensure all components are strings or functions.

The error occurs because the `Link` component from React Router expects a string for its `to` prop, but you're passing an object instead. To fix this, simply wrap the string in quotes.

⚠️ Common Causes

  • Incorrect usage of React Router components.

🛠️ Step-by-Step Verified Fixes

Method 1: Correct Usage of Link Component

  1. Step 1: Pass the string 'about' as the value for the `to` prop.

Method 2: Correct Usage of Link Component

  1. Step 1: Pass the string 'about' as the value for the `to` prop.

🎯 Final Words

By following these steps, you can resolve the error and successfully use the Link component from React Router.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions