Home > Net >  How to call library API of react-native-curved-bottom-bar
How to call library API of react-native-curved-bottom-bar

Time:12-10

please help me with the api library call.

I'm using the "react-native-curved-bottom-bar" library, where the readme lists the setVisible(boolean) function to hide the menu. However, I don't know where and how to call this function.

Link to the package: https://github.com/hoaphantn7604/react-native-curved-bottom-bar

CodePudding user response:

When a component has a function available, you have to call that function on the component reference directly. The common way to do this is to store the instance in a ref, and then call the function on the ref. Ex:

  const tabBarRef = useRef(null);

  const hideTabBar = () => {
    tabBarRef.current?.setVisible(false);
  };

  return <TabBar ref={tabBarRef} />;

You should access the instance optionally (.current?.setVisible) because the ref won't be populated until the first render of the screen.

  • Related