[英]Initializing component with parameter set from other page in nextjs
I have 2 components on separate pages in nextjs.我在 nextjs 的不同页面上有 2 个组件。 The way I would like my app to work is:
我希望我的应用程序工作的方式是:
Below the component provided by the external service for reference:下面由外部服务提供的组件供参考:
<WebSdk
accessToken={token}
expirationHandler={handler}
config={config}
options={options}
onMessage={messageHandler}
onError={errorHandler}
/>
How should I store and read the access token?我应该如何存储和读取访问令牌? Do I need to use
useState
or useEffect
?我需要使用
useState
还是useEffect
吗? Do I need to set a cookie or localStorage?我需要设置 cookie 或 localStorage 吗?
Neither useState
nor useEffect
is good choice for this condition.对于这种情况,
useState
和useEffect
都不是好选择。
You can use both cookies(low security)
and localStorage
, but I recommend using sessionStorage(it has expire time)
.I您可以同时使用
cookies(low security)
和localStorage
,但我建议使用sessionStorage(it has expire time)
。我
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.