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

How to access component method outside of component? #91

Closed
kokjinsam opened this issue Oct 17, 2015 · 1 comment
Closed

How to access component method outside of component? #91

kokjinsam opened this issue Oct 17, 2015 · 1 comment
Labels

Comments

@kokjinsam
Copy link

Hi,

I have been exploring this awesome package for two weeks now. It's awesome! Thanks for your hard work!

Due to the fact I'm still new to this package, please excuse my noobiness. How do I access a component method outside of the component? For example, I have a hide() function in headerComponent and I want to use the hide function from contentComponent. How do I do that?

and if I want to use the hide function from a non BC, how should I do that?

@mitar mitar added the question label Oct 17, 2015
@mitar
Copy link
Member

mitar commented Oct 17, 2015

You should traverse the tree of components using childrenComponents or parentComponent methods (possibly calling it recursively), finding the component you want, and calling a method on it.

Where exactly you want to call it from outside a component? In general you simply have to have a reference to the component. You can store it somewhere, for example. You can also use getComponentForElement to get a component from a DOM element.

See also #81 and #82.

@mitar mitar closed this as completed Oct 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants