Guided Tour / Joyride Integration to my Website(导游/兜风集成到我的网站)
问题描述
我想为我的 React 应用添加兜风或导游.我想在用户第一次使用它时显示它,并为随后的频繁访问禁用它.我找到了这个库 https://github.com/gilbarbara/react-joyride 但不能不知道如何在同一用户的后续访问中禁用?我可以使用 localstorage 或 cookie 来处理这个问题吗?怎么样?
I want to add a joyride or guided tour for my React App. I want to show it when the users first uses it and disable for subsequent frequent visits. I have found this library https://github.com/gilbarbara/react-joyride but couldn't figure out how to disable on subsequent visits by same user? Can I use localstorage or cookies to deal with this issue? How?
推荐答案
如果你使用的是nextjs或者服务端渲染,这是我的做法:
If you're using nextjs or server-side rendering, here's my approach:
状态已初始化:
runJoyride: (typeof window === 'undefined')? false : window.localStorage.getItem('onboarded') === null,
然后你回电:
handleJoyrideCallback = data => {
const { action, index, status, type } = data;
if ([STATUS.FINISHED, STATUS.SKIPPED].includes(status)) {
this.setState({ runJoyride: false });
window.localStorage.setItem('onboarded', true);
}
};
这篇关于导游/兜风集成到我的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:导游/兜风集成到我的网站
基础教程推荐
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
