在带有redux的react-native中使用firebase orderByChild时出现未指定的警告

时间:2019-02-02 21:41:34

标签: firebase react-native redux

在我的本机项目中添加orderByChild Firebase过滤器时,我得到了一个神秘的黄框错误,即使该应用正在读取和过滤数据也很好。

如果我删除orderByChild,一切正常。

代码给出警告:

export const peopleFetchAll = ({ name }) => {
console.log(`${name}`);

return (dispatch) => {
  firebase.database().ref(`/people`).orderByChild("name").equalTo("Paul")
    .once('value', snapshot => {
        dispatch({ type:PEOPLE_FETCH_SUCCESS, payload:snapshot.val() });
    });
  };
};

好的代码:

export const peopleFetchAll = ({ name }) => {
console.log(`${name}`);

return (dispatch) => {
  firebase.database().ref(`/people`)
    .once('value', snapshot => {
        dispatch({ type:PEOPLE_FETCH_SUCCESS, payload:snapshot.val() });
    });
  };
};

我在Expo上看到的错误是:

▼[2019-02-02T21:25:30.973Z]  @firebase/database:
- node_modules\react-native\Libraries\ReactNative\YellowBox.js:80:15 in warn
- node_modules\expo\src\Expo.js:25:41 in warn
- node_modules\@firebase\logger\dist\index.cjs.js:66:31 in defaultLogHandler
- node_modules\@firebase\logger\dist\index.cjs.js:152:31 in warn
- node_modules\@firebase\database\dist\index.cjs.js:345:19 in warn
- node_modules\@firebase\database\dist\index.cjs.js:11818:21 in warnOnListenWarnings_
- node_modules\@firebase\database\dist\index.cjs.js:11788:55 in <unknown>
- node_modules\@firebase\database\dist\index.cjs.js:12052:27 in onDataMessage_
- node_modules\@firebase\database\dist\index.cjs.js:11337:24 in onDataMessage_
- node_modules\@firebase\database\dist\index.cjs.js:11331:32 in onPrimaryMessageReceived_
- node_modules\@firebase\database\dist\index.cjs.js:11232:52 in <unknown>
- node_modules\@firebase\database\dist\index.cjs.js:10837:27 in appendFrame_
- node_modules\@firebase\database\dist\index.cjs.js:10887:34 in handleIncomingFrame
- node_modules\@firebase\database\dist\index.cjs.js:10784:38 in onmessage
- node_modules\event-target-shim\lib\event-target.js:172:43 in dispatchEvent
- node_modules\react-native\Libraries\WebSocket\WebSocket.js:239:27 in <unknown>
- node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:180:12 in emit
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:351:47 in __callFunction
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:116:26 in <unknown>
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:314:6 in __guardSafe
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:115:17 in callFunctionReturnFlushedQueue

同样,即使我得到警告,一切都正常。我只需要摆脱警告,我似乎无法破译。

1 个答案:

答案 0 :(得分:1)

您是否在name下的/people上定义了索引,如下所示:firebase.google.com/docs/database/security/indexing-data?

如果没有,那可能是发出警告的原因,尽管我不明白为什么它不会显示实际的警告消息。