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

Bug located to use react-native-material-menu?! #127

Open
John-CFO opened this issue Feb 18, 2024 · 0 comments
Open

Bug located to use react-native-material-menu?! #127

John-CFO opened this issue Feb 18, 2024 · 0 comments

Comments

@John-CFO
Copy link

John-CFO commented Feb 18, 2024

Hi guys,

I try to implement the react-native-material-menu library in my project.
The problem is, that the menu open in the headerRight (as I expect) and also in the headerLeft.
Any idea how to fix it?

Menu_bug.mp4

My depedencies are the current as:

"dependencies": {
"@react-navigation/drawer": "^6.6.6",
"@react-navigation/native": "^6.1.9",
"@react-navigation/stack": "^6.3.20",
"expo": "^50.0.7",
"expo-status-bar": "~1.11.1",
"react": "18.2.0",
"react-native": "^0.73.4",
"react-native-gesture-handler": "^2.14.1",
"react-native-material-menu": "^2.0.0",
"react-native-reanimated": "^3.6.2",
"react-native-safe-area-context": "^4.8.2",
"react-native-screens": "^3.29.0"
}

//MaterialMenu.tsx

interface`` HelpMenuProps { onClose: () => void; }

const HelpMenu: React.FC<HelpMenuProps> = ({ onClose }) => {
  const closeMenu = () => {
    onClose(); };

  return (
        <TouchableOpacity onPress={closeMenu}>
          <MaterialCommunityIcons name="close-circle" size={38} color="white" />
        </TouchableOpacity> );


//App.tsx

 import { Menu } from "react-native-material-menu";
 import MaterialMenu from "./components/MaterialMenu";

 const AppDrawerNavigator = () => {
  const [isMenuVisible, setMenuVisible] = useState(false);

  const showMenu = () => setMenuVisible(true);
  const hideMenu = () => setMenuVisible(false);

  const menuComponent = (
    <Menu
      visible={isMenuVisible}
      anchor={
        <TouchableOpacity onPress={showMenu} style={{ marginRight: 10 }}>
          <MaterialIcons name="live-help" size={36} color="black" />
        </TouchableOpacity>
      }
      onRequestClose={hideMenu} 
      >
      <MaterialMenu onClose={hideMenu} />
    </Menu>
  );

  return (
    <Drawer.Navigator
      initialRouteName="Home"
      screenOptions={{
        headerTitleAlign: "center",
        drawerStyle: {
          width: 280, },
        /*--Help-Button--*/
        headerRight: () => (
          <React.Fragment key={"menu"}>{menuComponent}</React.Fragment>
        ),
      }}
    >
      <Drawer.Screen name="Home" component={HomeScreen} />
      <Drawer.Screen name="Notification" component={NotificationScreen} />
      <Drawer.Screen name="Profile" component={ProfileScreen} />
    </Drawer.Navigator>
       );
}; 


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

1 participant