[英]Sanity CMS: Get current user from datastore
I'm trying to fetch the current user in Sanity CMS.我正在尝试在 Sanity CMS 中获取当前用户。
I found this code snippet which demonstrates use of userStore我发现这个代码片段演示了userStore 的使用
But I don't understand how I can configure my project to accept this module lookup但我不明白如何配置我的项目以接受此模块查找
import userStore from 'part:@sanity/base/user';
It throws an import error Cannot find module 'part:@sanity/base/user'
.它引发导入错误
Cannot find module 'part:@sanity/base/user'
。 Which makes sense as its a non standard node module.作为非标准节点模块,这是有道理的。
Inspecting that @sanity
source I can see base/lib/datastores
which has a userStore
it's just not obvious how to consume this.检查那个
@sanity
源我可以看到base/lib/datastores
有一个userStore
它只是不明显如何使用它。
So this example hook works and returns the User.所以这个示例钩子工作并返回用户。 Sanity is taking care of the module resolution.
Sanity 正在处理模块分辨率。 It's an IDE error not a runtime error in Sanity.
这是 IDE 错误,而不是 Sanity 中的运行时错误。
(╯°□°)╯︵ ┻━┻ (╯°□°)╯︵ ┻━┻
Their advice is to ignore these un resolved module warnings for part imports.他们的建议是忽略这些未解决的部件导入模块警告。
"eslintConfig": {
"rules": {
"import/no-unresolved": [2, { "ignore": ["^(all|part):"] }]
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.