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

context is empty in Component constructor #80

Closed
zeakd opened this issue May 8, 2018 · 2 comments
Closed

context is empty in Component constructor #80

zeakd opened this issue May 8, 2018 · 2 comments

Comments

@zeakd
Copy link

zeakd commented May 8, 2018

Hi. I'm making ink component using context which is used in ink-redux.

when I use getChildContext method, render contains context but constructor does not.

class Sub extends Component {
  constructor (props, context) {
    super(props, context);

    console.log(context); // {}
  }

  render (props, state, context) {

    console.log(context); // { hi: 'hello' }

    return (
      <Text blue>Hi</Text>
    )
  }
}

class Parent extends Component {
  getChildContext () {
    return {
      hi: 'hello'
    }
  }

  render () {
    console.log(this.context); // { hi: 'hello'}
    return (
        <Sub />
    );
  }
}

thanks!

@zeakd
Copy link
Author

zeakd commented May 8, 2018

I make a PR for this. #81

@vadimdemedes
Copy link
Owner

Closing, see #81.

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

2 participants