You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
-15Lines changed: 0 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -206,21 +206,6 @@ export default App;
206
206
207
207
It's also beneficial to use a [selector](https://github.com/Expensify/react-native-onyx/blob/main/API.md#connectmapping--number) with the mapping in case you need to grab a single item in a collection (like a single report action).
208
208
209
-
### useOnyx()'s `canBeMissing` option
210
-
211
-
You must pass the `canBeMissing` configuration flag to `useOnyx` if you want the hook to log an alert when data is missing from Onyx store. Regarding usage in `Expensify/App` repo, if the component calling this is the one loading the data by calling an action, then you should set this to `true`. If the component calling this does not load the data then you should set it to `false`, which means that if the data is not there, it will log an alert, as it means we are using data that no one loaded and that's most probably a bug.
212
-
213
-
```javascript
214
-
constComponent= ({reportID}) => {
215
-
// This hook will log an alert (via `Logger.logAlert()`) if `report` is `undefined`.
Collections allow keys with similar value types to be subscribed together by subscribing to the collection key. To define one, it must be included in the `ONYXKEYS.COLLECTION` object and it must be suffixed with an underscore. Member keys should use a unique identifier or index after the collection key prefix (e.g. `report_42`).
it('should log an alert if Onyx doesn\'t return data but there is a selector that always return something and "canBeMissing" property is false',async()=>{
1122
-
const{result: result1}=renderHook(()=>
1123
-
useOnyx(ONYXKEYS.TEST_KEY,{
1124
-
// This selector will always return a value, even if the Onyx data is missing.
// This test suite must be the last one to avoid problems when running the other tests here.
1175
1022
describe('canEvict',()=>{
1176
1023
consterror=(key: string)=>`canEvict can't be used on key '${key}'. This key must explicitly be flagged as safe for removal by adding it to Onyx.init({evictableKeys: []}).`;
0 commit comments