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

wrapper.context() API #146

Closed
blainekasten opened this issue Jan 28, 2016 · 2 comments
Closed

wrapper.context() API #146

blainekasten opened this issue Jan 28, 2016 · 2 comments

Comments

@blainekasten
Copy link
Contributor

Similar to wrapper.props, there should be an api to introspect into the context of a component.

The vernacular is sort of weird if we want to mimic the prop/props style as it would be:

wrapper.contexts() // returns entire context object
wrapper.context('foo') // returns foo from the context object

Part of me thinks the word contexts sounds weird. We could do this for an API:

wrapper.context() // no argument - returns entire context object
wrapper.context('foo') // returns foo from the context object

though this might cause some confusion and unreliability to the API. Thoughts?

@lelandrichardson
Copy link
Collaborator

@blainekasten the .state() and .state('foo') API is like the latter and I think would make sense...

I'm not strictly sure we are able to do this though? We might need to specify childContextTypes before-hand.... I'm really not sure though.

@blainekasten
Copy link
Contributor Author

I've been doing it hackily by this code:

wrapper.node.context; // full context
wrapper.node.context[arg] // context item

Is it not internally safe to depend on the node item? If it is, this API could be really simple to implement. I'll give it a test in a bit.

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