ctrlplusb / react-jobs

Asynchronously resolve data for your components, with support for server side rendering.
MIT License
166 stars 34 forks source link

shouldWorkAgain invoke the constructor with React 16 #50

Open stelro opened 6 years ago

stelro commented 6 years ago

Hello, I don't know if this is the normal behavior, but every time shouldWorkAgain is called, the constructor of the component is invoked, thus is construct the component again every time. This happens after I upgraded to React 16, with React 15 I don't have this behavior.

Here is my code :

@inject('userStore')
@withRouter
@observer
@withJob({
  work: ({ userStore, match }) => {
      return userStore.fetchUserListings(match.params.params);
  },
  shouldWorkAgain: (prev, next) => {
    return (prev.match.params.params !== next.match.params.params);
  },
  LoadingComponent,
  ErrorComponent,
  serverMode: 'defer',
})
export default class UpListingsView extends Component {
  //....
}
ctrlplusb commented 6 years ago

Hey @stelro

Sorry for the late reply. I have been doing some update rounds on my libs and am trying to push this lib forward.

Would you be happy to create a minimal example of this on codesandbox.io?