I have pages or large components that need to be rendered after the main page loads. I have them lazily loaded but am getting an error when I use in createElement()
:
LazyExoticComponent | LazyExoticComponent is not assignable to parameter of type 'string | FunctionComponent<RefAttributes> | ComponentClass<RefAttributes, any>'
What I've tested:
import Page2 from "./Page2";
import Page3 from "./Page3";
const pages = [Page2, Page3];
//in any method in the react component
let s = [Page2];
let ss = [Page2, Page3];
let sss = pages[0];
let r = React.createElement(s[0]); //this works
let rr = React.createElement(ss[0]); //does not work
let rrr = React.createElement(sss); //does not work
Using latest versions of Typescript, React, React-Scripts does not seem to have any affect.
Typescript ^3.9.9, React ^16.14.0, React-Scripts ^2.1.8, "@types/react": "^17.0.0", "react-dom": "^16.13.1", no @types/react-dom