盖茨比在构建时间上用链接组件替换常规锚标签
我们已经在组件中使用一些常规的锚标签创建了我们的设计系统。现在的问题是,在使用盖茨比(Gatsby)中使用这些组件时,由于常规的锚标签,整个页面正在重新加载到新页面。我知道Gatsby有一个链接
组件,但是我们无法在库中实现此问题,因此有什么方法可以克服此问题吗?
we have created our design system with a few regular anchor tags in the components. now the problem is, while using those components in gatsby, the whole page is getting reloaded while Navigating to a new page due to regular anchor tags. I know that gatsby has a Link
component but we can't implement this in our library, So is there any way to overcome this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在互联网上搜索了几个小时后,我找到了上述问题的解决方案,我尝试了 gatsby-plugin-catch-links 此插件在内部使用锚定标签, event.preventdefault()用于防止页面重新加载&检测点击事件&将其应用于使用Gatsby的
navigate()
挂钩进行编程导航,因此最终它解决了我的问题。After a few hours of searching through the internet, finally, I found the solution for the above issue, I have tried gatsby-plugin-catch-links this plugin internally uses an anchor tag with the event.preventDefault() for preventing the page from reloading & detects click event & applies it to navigate programmatically using gatsby's
navigate()
hook, So finally it resolves my issue.