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

SideMenu is visible below the component it is rendered on #374

Open
aejaex opened this issue Feb 8, 2019 · 6 comments
Open

SideMenu is visible below the component it is rendered on #374

aejaex opened this issue Feb 8, 2019 · 6 comments

Comments

@aejaex
Copy link

aejaex commented Feb 8, 2019

Hi,

I have created the SideMenu as per the example here, however, the SideMenu is visible beneath the component I am rendering it on, even though the toggle state may be closed. I can even see it between screen transitions, until the main component gets rendered over it.

How can I fix this?

@vinay-webrmedia
Copy link

vinay-webrmedia commented Feb 20, 2019

@aejaex I am facing the same issue. I have found a work around. I hope it helps you.
I added props isVisible to the Menu component which will control if the menu should be displayed or no.
I am passing the this.state.showSideMenu as the value for isVisible props which controls the SideMenu's isOpen props.

render() {
   const menu = <Menu isVisible={this.state.showSideMenu} />;
   return (
     <SideMenu
       menu={menu}
       menuPosition="right"
       isOpen={this.state.showSideMenu}
     >
        <Text>Welcome to Side Menu Demo</Text>
    </SideMenu>
);

Menu.js

import React, { Component } from 'react';
import { View, Text } from 'react-native';
export default class Menu extends Component {
  constructor(props) {
    super(props);
    this.state = {
      isVisible: props.isVisible
    }
  }

  componentWillReceiveProps(nextProps) {
    if (nextProps.isVisible != this.props.isVisible) {
      this.setState({isVisible: nextProps.isVisible});
    }
  }

  render() {
    return (
      <View style={{flex: 1}}>
        {
          this.state.isVisible ? 
            <View style={{flex: 1}}>
              <Text>I am side menu content</Text>
            </View> :
          null

        }
      </View>
    );
  }
}

@shoonne
Copy link

shoonne commented Mar 25, 2019

Does someone have a solution to this? I have my side menu wrapped around my App.js which makes it accessable in other files. When i swipe in my app, the menu is visible below the components

@aejaex
Copy link
Author

aejaex commented Mar 25, 2019

I switched over to NativeBase's Drawer, which I found easier to use and more robust.

@duytq94
Copy link

duytq94 commented Apr 3, 2019

@aejaex
I have the same issue, you should set your ContentView with background color like white or another solid color to hide the side menu when it doesn't open.

@lyzkhqby
Copy link

I get SideMenu by ref,then invoke the ”openMenu" function of the ref

@dezudas
Copy link

dezudas commented Jun 7, 2020

@aejaex I am facing the same issue. I have found a work around. I hope it helps you.
I added props isVisible to the Menu component which will control if the menu should be displayed or no.
I am passing the this.state.showSideMenu as the value for isVisible props which controls the SideMenu's isOpen props.

render() {
   const menu = <Menu isVisible={this.state.showSideMenu} />;
   return (
     <SideMenu
       menu={menu}
       menuPosition="right"
       isOpen={this.state.showSideMenu}
     >
        <Text>Welcome to Side Menu Demo</Text>
    </SideMenu>
);

Menu.js

import React, { Component } from 'react';
import { View, Text } from 'react-native';
export default class Menu extends Component {
  constructor(props) {
    super(props);
    this.state = {
      isVisible: props.isVisible
    }
  }

  componentWillReceiveProps(nextProps) {
    if (nextProps.isVisible != this.props.isVisible) {
      this.setState({isVisible: nextProps.isVisible});
    }
  }

  render() {
    return (
      <View style={{flex: 1}}>
        {
          this.state.isVisible ? 
            <View style={{flex: 1}}>
              <Text>I am side menu content</Text>
            </View> :
          null

        }
      </View>
    );
  }
}

It worked for me with small glitch. It will hide the sidemenu once you click the close, then animation goes in blank area.

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

6 participants