3

I'm having this problem 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. when I try to import a icon from React-Icons in my NextJs app.

See my code below.

import React from "react";

import MdPlayCircleOutline from "react-icons";

const Podcast = props => {
  return (
    <div className="podcast">
      <div className="podcastName">
        <h4>{props.title}</h4>
      </div>

      <MdPlayCircleOutline />
    </div>
  );
};

export default Podcast;

Why this?

2
  • Can you try importing like this: import {MdPlayCircleOutline} from "react-icons" Commented Feb 17, 2019 at 2:47
  • Yes, I've tried but not work Commented Feb 17, 2019 at 2:51

1 Answer 1

6

Each icon set has their own folder. For Material Design icons, it is './md'. So, the import should be:

import { MdPlayCircleOutline } from 'react-icons/md' 

See: http://react-icons.github.io/react-icons/#usage

Sign up to request clarification or add additional context in comments.

1 Comment

Wow, I had not noticed that. Thanks you very much bro!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.