schiehll / react-alert

alerts for React
MIT License
608 stars 98 forks source link

next.js getInitialProps is consumed by withAlert #139

Closed simb4 closed 4 years ago

simb4 commented 5 years ago

next.js static method getInitialProps is consumed by HOC. I assume it erases it on some step. Not sure why.

class Index extends React.Component {
  static async getInitialProps({ store, query }) {
    return { x: 5 };
  }

  render() {
    console.log(this.props.x); // undefined

  }
}
export default withAlert()(Index);

I think, it is not expected behavior.

besLisbeth commented 5 years ago

Hi @simb4. getInitialProps should not be consumed by withAlert HOC as it redirects the props to the wrapped Component Do you have a sandbox with not working example?