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
@@ -154,37 +154,51 @@ Specifying `rollback` functions are not required. However, it is recommended for
154
154
155
155
### `connectRequest`
156
156
157
-
Use the `connectRequest` higher-order component to declare network dependencies for a React component. `connectRequest` takes a function that transforms the component `props` to a request query config or an array of request query configs. Example usage:
157
+
Use the `connectRequest` higher-order component to declare network dependencies for a React component.
158
+
159
+
`connectRequest` takes a function, `mapPropsToConfigs`, that transforms the component `props` to a request query config or an array of request query configs. You can think of `mapPropsToConfigs` similarly to `react-redux`'s `mapStateToProps` and `mapDispatchToProps`.
160
+
161
+
On mount, every query config returned from `mapPropsToConfigs` will result in a dispatched `requestAsync` Redux action. When the props update, `mapPropsToConfigs` is called again. All pending requests that were removed will be cancelled and all new configs will result in a dispatched `requestAsync` Redux action. On unmount, all pending requests will be cancelled.
162
+
163
+
Please note, just because a `requestAsync `Redux action was dispatched, does not mean that an actual network request will occur. Requests that were previously successful will not result in another network request, unless the corresponding query config has `force` set to `true`.
164
+
165
+
99% of the time you'll be using `react-redux`'s `connect` at the same time when you are using `connectRequest`. You might find using `redux`'s `compose` function makes this a bit more elegant.
`connectRequest` passes an extra prop to the child component: `forceRequest`. Calling this function will cause the request(s) to be made again. This may be useful for polling or creating an interface to trigger refreshes.
@@ -197,16 +211,16 @@ Dispatch `mutateAsync` Redux actions to trigger mutations. `mutateAsync` takes a
0 commit comments