0
votes

I am new to react , This same code is working in the tutorial. Please check this code.

import React from 'react';
import './SidebarOption.css';

function SidebarOption({ text, Icon }) {
  return (
    <div className="sidebarOption">
      <Icon />
      <h2>{text}</h2>
    </div>
  )
}

export default SidebarOption;

This Error only shows up when I add the Component

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

1
Can you share the code for how you are passing Icon to this coponent?Guruparan Giritharan

1 Answers

0
votes
import './SidebarOption.css';

function SidebarOption( {text, Icon}) {
    return (
        <div className="sidebarOption">
          {Icon}
          <h2>{text}</h2>
        </div>
    )
}

export default SidebarOption;