alexandernst
alexandernst

Reputation: 15109

Finding parent refs

I have a <Skylight ref="foo".... /> component in my main Layout. How would I show the modal dialog of Skylight from a child component?

I mean, how would I call this.refs.foo.show() in my component and make this.refs.foo point to the Skylight component that is 3 or 4 levels up in the DOM?

Upvotes: 1

Views: 40

Answers (1)

linguamachina
linguamachina

Reputation: 5803

You could introduce a top-level container component for modal dialogs, that populates its children based on the state of a collection in your top-level store. Then the child component could dispatch an action to create a modal dialog.

I implemented something similar for toast-style notifications; will post an example when I'm back at a keyboard...

Upvotes: 1

Related Questions