universal-async-component icon indicating copy to clipboard operation
universal-async-component copied to clipboard

React 16.x TypeError: Object(...) is not a function

Open yss14 opened this issue 7 years ago • 1 comments

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"
  },

yss14 avatar Feb 06 '18 14:02 yss14

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

mohsen1 avatar Feb 06 '18 17:02 mohsen1