【问题标题】:TypeError: Proxy has already been revoked. No more operations are allowed to be performed on itTypeError:代理已被撤销。不允许对其进行更多操作
【发布时间】:2022-08-11 16:22:23
【问题描述】:

我在 Store 的 react-native 上使用 easy-peasy v5,每次尝试在 thunk 中调用操作时都会引发错误。

fetch: thunk(async (actions, teamId, { getStoreActions }) => {
    // get data of all items
   /* ... */
    try {
      getStoreActions().account.users.fetched(...);
    } catch (e) {
      console.log(\"Store Error (teams/fetch) 93 \", e);
    }

    try {
      actions.fetchedMembers(...);
    } catch (e) {
      console.log(\"Store Error (teams/fetch) 101 \", e);
    }
    // get teams by id, and the ids
    /* ... */
    // update store data
    try {
      actions.fetched(...);
    } catch (e) {
      console.log(\"Store Error (teams/fetch) 114 \", e);
    }
    return data;
  }),

此 thunk 调用输出:

Store Error (teams/fetch) 93  [TypeError: Proxy has already been revoked. No more operations are allowed to be performed on it]
Store Error (teams/fetch) 101  [TypeError: Proxy has already been revoked. No more operations are allowed to be performed on it]
Store Error (teams/fetch) 114  [TypeError: Proxy has already been revoked. No more operations are allowed to be performed on it]

该问题不是第一次出现(清除所有缓存和存储后),而是在每次连续启动时出现。 我在带有 AsyncStorage 的 react-native 上使用 easy-peasy 的 persist 函数。

如果没有persist,错误的数量会减少。

我必须启用其他设置才能使持久性正常工作:

  • setAutoFreeze: 假
  • window.requestIdleCallback:空

    标签: reactjs react-native redux react-redux easy-peasy


    【解决方案1】:

    我在 React Native iOS 上遇到了同样的错误并修复了它。 尽量不要返回您的状态的新不可变实例,只需进行如下更改:

      addItem: action((state, payload) => {
        const itemId = payload;
        // ✌? modify the array or other value directly like:
        state.items.push(itemId);
        // ❌ rather than return new state
        // return {
        //   ...state,
        //   items: [...state.items, itemId],
        // };
      }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-27
      • 2010-10-04
      • 1970-01-01
      • 1970-01-01
      • 2011-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多