Skip to content

React.createElement: type is invalid #193

Description

@jankarres

I would love to use your react-player package with its well documented API, but I get an issue by just using your example. I write my code in TypeScript 2.x compiled to ES5. So the code looks a little bit different to normal JavaScript, but you provide an index.d.ts, so I think it should work with Typescript, too.

Integration of your player (simplified):

import * as React from "react";
import { render } from "react-dom";
import "../public/css/main.css";

import ReactPlayer from "react-player";

render(
  (
    <ReactPlayer url="https://www.youtube.com/watch?v=ysz5S6PUM-U" />
  ),
  document.querySelector("#app")
);

Stacktrack:

warning.js:36 Warning: React.createElement: 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.
printWarning @ warning.js:36
warning @ warning.js:60
createElement @ ReactElementValidator.js:190
(anonymous) @ index.tsx:7
__webpack_require__ @ bootstrap e2420a7…:555
fn @ bootstrap e2420a7…:86
(anonymous) @ bootstrap e2420a7…:578
__webpack_require__ @ bootstrap e2420a7…:555
(anonymous) @ bootstrap e2420a7…:578
(anonymous) @ bootstrap e2420a7…:578
invariant.js:44

Uncaught 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.
    at invariant (invariant.js:44)
    at ReactCompositeComponentWrapper.instantiateReactComponent [as _instantiateReactComponent] (instantiateReactComponent.js:74)
    at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:367)
    at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:258)
    at Object.mountComponent (ReactReconciler.js:46)
    at mountComponentIntoNode (ReactMount.js:104)
    at ReactReconcileTransaction.perform (Transaction.js:140)
    at batchedMountComponentIntoNode (ReactMount.js:126)
    at ReactDefaultBatchingStrategyTransaction.perform (Transaction.js:140)
    at Object.batchedUpdates (ReactDefaultBatchingStrategy.js:62)

Do you have any idea what is wrong here? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions