justinmc / react-audio-player

A simple React wrapper on the HTML5 audio tag
MIT License
589 stars 104 forks source link

Element type is invalid: expected a string (for built-in components) #96

Closed jkmuka closed 4 years ago

jkmuka commented 4 years ago

Getting this error when added to CRA, using react and react-dom v17.0

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.

import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import * as serviceWorker from "./serviceWorker";
import { ReactAudioPlayer } from "react-audio-player";

ReactDOM.render(
  <React.StrictMode>
    <ReactAudioPlayer
      src="/1547564388146-1547014143594-14437430600-x1001u1_E-1001.au"
      autoPlay
      controls
    />
  </React.StrictMode>,
  document.getElementById("root")
);

serviceWorker.unregister();
jkmuka commented 4 years ago

changed import statement to remove {} around ReactAudioPlayer

import ReactAudioPlayer from "react-audio-player";

irodger commented 3 years ago

Tried to import as import ReactAudioPlayer from 'react-audio-player'; and import * as ReactAudioPlayer from 'react-audio-player'; But has the same error: Element type is invalid: expected a string