universal-async-component
universal-async-component copied to clipboard
React 16.x TypeError: Object(...) is not a function
I just wanted to try out this fancy library, but it doesn't seem to work with react 16.x.
The error is thrown in line 5.
import * as React from 'react';
import './App.css';
import { getComponentAsync } from 'universal-async-component';
const AsyncHelloWorld = getComponentAsync({ loader: () => import('./Test') });
class App extends React.Component {
render() {
return (
<div className="App">
<AsyncHelloWorld />
</div>
);
}
}
export default App;
"dependencies": {
"lodash": "^4.17.5",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-scripts-ts": "2.13.0",
"universal-async-component": "^1.0.1"
},
Just updated the example repo with React 16 and it seems to be working
https://github.com/mohsen1/universal-async-component-example/pull/2
Can you make sure you are not compiling import()
s with Babel or TypeScript? Webpack must see those import()
statements for this to work