bundle-loader icon indicating copy to clipboard operation
bundle-loader copied to clipboard

a warning and a problem

Open gitdust opened this issue 7 years ago • 4 comments

warning as below: image an a problem is that when I start a fetch in React component's lifecycle, this fetch never ends.

gitdust avatar Dec 01 '17 07:12 gitdust

@gitdust can you create minimum reproducible test repo?

alexander-akait avatar Dec 01 '17 09:12 alexander-akait

actually I use this demo to code spliting,it seems that the problem is in this demo.My project is so big, I'll try my best to create a test repo.

gitdust avatar Dec 05 '17 07:12 gitdust

I have the same problem, this is my solution.

this.state = {
      isMounted: false
    }
 componentDidMount() {
    this.setState({ isMounted: true })
  }
  componentWillUnmount() {
    this.setState({ isMounted: false })
  }
load(props) {
    this.setState({
      mod: null
    })
    props.load((mod) => {
      if (this.state.isMounted) {
        this.setState({
          // handle both es imports and cjs
          mod: mod.default ? mod.default : mod
        })
      }
    })
  }

I hope this works

RedJue avatar Jan 09 '18 15:01 RedJue

@RedJue it worked for me,thanks very much. But still have any clue about this infinite fetch.

gitdust avatar Jan 10 '18 05:01 gitdust