gpt4 book ai didi

javascript - 如何在继电器现代中设置初始变量?

转载 作者:行者123 更新时间:2023-12-01 03:39:50 25 4
gpt4 key购买 nike

在 learnrelay.org 上开始中继,从教程中设置初始变量的代码 https://www.learnrelay.org/queries/variables/是这样的:

export default Relay.createContainer(
ListPage,
{
initialVariables: {
sortOrder: 'id_DESC'
},
fragments: {
viewer: () => Relay.QL`
fragment on Viewer {
allPokemons (first: 1000, orderBy: $sortOrder) {

我们通常在relay classic中像这样分配变量,但是这段代码在relay Modern中会抛出错误,我不知道为什么?

export default createPaginationContainer(TodoList,
initialVariables: {
first: 10,
},
fragments: {
viewer: graphql`
fragment TodoList_viewer on User {
todos( # we need to expose todos on user so we can check if todo text already exist and sync in database
first: $first
) @connection(key: "TodoList_todos") { #assign a key of connection that can be used shared updater

最佳答案

您不能在 Relay Modern 中使用 initialVariables - see this link in the docs 。 请注意,到目前为止,从这些功能迁移的文档非常简短。

如果您现在正在处理此问题,有一个 pending updateRefetchContainer documentation这展示了如何根据变量正确获取和重新获取 View 。

如果您仅使用变量进行分页,check out PaginationContainer .

关于javascript - 如何在继电器现代中设置初始变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43983236/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com