如何使用 React 或 Gatsby 在 url 中处理(获取、设置)查询字符串(whitout window || 文档)

How to work (get, set) with query string in a url using react or Gatsby (whitout window || document)

如何使用 React 或 Gatsby 获取或设置查询字符串(不使用文档或 window 对象):

https://link.com/?color=#fff&theme=light

您可以将此模块用于 reacthttps://github.com/pbeshai/use-query-params

对于 gatsby,您可以使用此插件: https://www.gatsbyjs.com/plugins/gatsby-plugin-use-query-params/ 它会用 QueryParamProvider

包装你的应用