UNPKG

@nghinv/react-native-app-tour

Version:
41 lines (37 loc) 1.28 kB
/** * Created by nghinv on Wed Jun 23 2021 * Copyright (c) 2021 nghinv@lumi.biz */ import React, { useRef, useState } from 'react'; import equals from 'react-fast-compare'; import { useSharedValue } from 'react-native-reanimated'; import AppTourView from './AppTourView'; import { AppTourContext } from './AppTourContext'; AppTourProvider.defaultProps = {}; // eslint-disable-next-line import/no-mutable-exports let AppTour; function AppTourProvider(props) { var _props$sceneIndex, _props$scenes; const { children, options } = props; const [sceneIndex, setSceneIndex] = useState((_props$sceneIndex = props.sceneIndex) !== null && _props$sceneIndex !== void 0 ? _props$sceneIndex : 0); const nodes = useSharedValue([]); const scenes = useRef((_props$scenes = props.scenes) !== null && _props$scenes !== void 0 ? _props$scenes : []).current; return /*#__PURE__*/React.createElement(AppTourContext.Provider, { value: { nodes, options, scenes, sceneIndex, setSceneIndex } }, children, /*#__PURE__*/React.createElement(AppTourView, { ref: ref => { AppTour = ref; } })); } export default /*#__PURE__*/React.memo(AppTourProvider, equals); export { AppTour }; //# sourceMappingURL=AppTourProvider.js.map