有条件的路由对日期
我正在ReactJ中构建一个网站,该网站允许用户在工作日填写表格,但在周末重定向到封闭页面。我如何使用React-Router-dom有条件地路由到其他页面?我也希望它不是当地时间,但是根据PST的说法。 谢谢!
I'm building a website in ReactJS that allows users to fill out a form during the weekday but redirects to a closed page on the weekend. How would I conditionally route to a different page using react-router-dom? I'd also like it to not be local time, but according to, say, PST.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在不知道您的确切路由器设置的情况下,我只能猜测,但这里有一些想法:
usenavigate
钩子:注意
使用> useeffect
的使用,您希望在安装决定是否应执行重定向的组件时检查逻辑。< redirect/>
组件:Without knowing your exact router setup, I can only guess, but here are some ideas:
The
useNavigate
hook:Note the use of
useEffect
, you want the logic to be checked upon mounting the component that decides whether the redirect should be performed or not.<Redirect />
component: