V
V
Vanya Huk2019-04-16 21:09:14
React
Vanya Huk, 2019-04-16 21:09:14

How to disable splitting in webpack?

there is a HOC - component:

import React, {Component} from "react";
function asyncComponent(getComponent) {
  class AsyncComponent extends Component {
    constructor(props) {
      super(props);
      this.state = {Component: AsyncComponent.Component};
    }
    componentWillMount() {
      if ( !this.state.Component ) {
        getComponent().then(Component => {
          AsyncComponent.Component = Component;
          this.setState({Component})
        })
      }
    }
    render() {
      const {Component} = this.state;
      if (Component)
        return <Component {...this.props} />;

      return null;
    }
  }
  return AsyncComponent;
}
export default asyncComponent;

and its use for dynamic loading:
import asyncComponent from '../AsyncComponent';

const Account = asyncComponent(() =>
  import('../layouts/Account').then(module => module.default)
);

The question is how to configure webpack so that SSR works because the node swears at the window.jsonp object on the server

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question