Skip to content

Commit

Permalink
make useReverse() not depend on current route;
Browse files Browse the repository at this point in the history
improve id detection in outbox delete
  • Loading branch information
sheppard committed Aug 31, 2023
1 parent a025328 commit 265d8e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/outbox/src/outbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ class Outbox {
data,
options,
});
data = item.data;
options = item.options;

var currentId;
if (data && data.id) {
Expand All @@ -193,6 +191,9 @@ class Outbox {
}
}

options = item.options;
data = item.data;

var type, payload, commitType, rollbackType;
const model = this._getModel(options.modelConf);
if (model) {
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ export function useRouteTitle(routeName) {
}

export function useReverse() {
const location = useSelector(selectLocationState);
const routesMap = useRoutesMap();
return useCallback(
(name, payload, query) => {
const action = {
type: name.toUpperCase(),
};
if (!location.routesMap[action.type]) {
if (!routesMap[action.type]) {
throw new Error(`Unknown route: ${action.type}`);
}
if (payload) {
Expand All @@ -139,7 +139,7 @@ export function useReverse() {
}
return action;
},
[location]
[routesMap]
);
}

Expand Down

0 comments on commit 265d8e2

Please sign in to comment.