Skip to content
This repository has been archived by the owner on Sep 13, 2020. It is now read-only.

menuActions outside of the scope? #15

Closed
PatrickHeneise opened this issue May 14, 2015 · 7 comments
Closed

menuActions outside of the scope? #15

PatrickHeneise opened this issue May 14, 2015 · 7 comments

Comments

@PatrickHeneise
Copy link

I'm trying to add a navbar with a button that should toggle the menu, but can't find where menuActions are exposed.

I tried various ideas with this.toggleMenu and having toggleMenu as a function in the menu class, but don't get it to work.

Any ideas?

    var menu = <Menu navigator={nav}/>;

    return (
      <View>
        <View>
          <TouchableOpacity onPress={() => menu.toggleMenu()}>
            <Text>Click</Text>
          </TouchableOpacity>
          <View>
            <Text>
              MyApp
            </Text>
          </View>
        </View>
        <SideMenu menu={menu}>
          <ItemView navigator={nav} />
        </SideMenu>
      </View>
    );
@Kureev
Copy link
Owner

Kureev commented May 15, 2015

I don't see any way to expose this functionality outside of SideMenu component. It can't be a static method as far as it use state to store current menu state. Why do you have this case? I mean isn't it enough to have an access to it in Menu component via prop?

@PatrickHeneise
Copy link
Author

It's a header/navbar outside of the sidebar and I don't want it to be pushed to the side like the content.

@Kureev
Copy link
Owner

Kureev commented May 15, 2015

But if you have content outside of the SideMenu, it's not gonna work: when you open/close menu, it move only the layer inside. It'll looks like your navbar has position: fixed.

@PatrickHeneise
Copy link
Author

The content is within SideMenu. It's just one button (hamburger icon) which is in the header to open/close the SideMenu.

@Kureev
Copy link
Owner

Kureev commented May 16, 2015

Okay, the only one thing I can do for you (and what actually I've made in 5.1 version) - is to pass props to the first-level children. I'd like to set up context, but it works weird now, so I'd like not to relay on it. On first-level components you can use this.props.menuActions to access API. Does it solve your request?

@Kureev Kureev mentioned this issue May 17, 2015
7 tasks
@PatrickHeneise
Copy link
Author

Yes, that should work. If menuActions are exposed there are lots of possibilities to control the menu. Thanks!

@Kureev
Copy link
Owner

Kureev commented May 18, 2015

You're welcome!

@Kureev Kureev closed this as completed May 18, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants