julekgwa / react-native-app-onboard

React Native App Onboard is a customizable, easy-to-use, and efficient library for creating compelling onboarding experiences for your React Native applications. It provides smooth, fluid transitions and animations, with a focus on simplicity and usability.
MIT License
2 stars 0 forks source link

useOnboarding Hook not Working #2

Closed znenet closed 1 week ago

znenet commented 2 weeks ago

Using:

import { Onboarding, useOnboarding } from 'react-native-app-onboard';

const OnboardingScreen = ({ navigation}) => {
    const { currentPage } = userOnboarding();
    return (
            <Onboarding .../>
    );
};
export default OnboardingScreen

throws the following error: useOnboardingContext must be used within an OnboardingProvider

julekgwa commented 2 weeks ago

Yes, you can only access it under <Onboarding>.

for example


const Page = () => {

  const {currentPage } = userOnboarding();

  return (
    <View>
      <Text>Page 1</Text>
    </View>
  );
};

const App = () => {
  return (
    <Onboarding>
      <Page />
    </Onboarding>
  );
}