ReactJS: React.render is not a function and React.createElement is not a function

前端 未结 3 1328
情话喂你
情话喂你 2020-12-29 05:57

I found a problem in my code when I was trying to use these two functions in my React version 15.2.0, nonetheless, I found a workaround but I would like to know if there\'s

3条回答
  •  一整个雨季
    2020-12-29 06:34

    I was getting error: "React.createElement is not a function" and for my situation the fix was to change this:

    import * as React from "react";
    import * as ReactDOM from "react-dom";
    

    TO THIS:

    import React from "react";
    import ReactDOM from "react-dom";
    

    This was in a TypeScript file so i'm not sure it applies to non-TypeScript or not.

提交回复
热议问题