Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadProps won't be called in class unless class is prefixed with "export default" #70

Open
OllieJennings opened this issue May 30, 2016 · 1 comment

Comments

@OllieJennings
Copy link

I could be wrong here, but from testing, there appears to be a bug in how the static method loadProps is called.

For example, the method won't be called (shown in code below):

export default ({ children }) => (
   children || <DefaultPage />
);


class DefaultPage extends Component {
  constructor(props) {
    super(props);
  }

  static loadProps(stuff, cb) {
    console.log('async props called');
    cb(null, {});
  }

  render() {
    return (
      <div className="pw__wrapper">
      </div>
    );
  }
}

But in the example below, the method will be called

export default class DefaultPage extends Component {
  constructor(props) {
    super(props);
  }

  static loadProps(stuff, cb) {
    console.log('async props called');
    cb(null, {});
  }

  render() {
    return (
      <div className="pw__wrapper">
      </div>
    );
  }
}

Not sure if this intended or not?

@OllieJennings OllieJennings changed the title loadProps won't be called in class unless class is "default export" loadProps won't be called in class unless class is prefixed with "export default" May 30, 2016
@OllieJennings
Copy link
Author

Also won't work unless it is the main class being called reference by routes in react-router

I.e. when using react-router unless the component being reference has the loadProps method in it, it will be called, however if it exists in any children components, it won't be called

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant