Skip to content

Commit

Permalink
return stable object for useModal
Browse files Browse the repository at this point in the history
  • Loading branch information
supnate committed Sep 27, 2023
1 parent 7fa8bad commit 65dee75
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,18 +356,32 @@ export function useModal(modal?: any, args?: any): any {
[mid],
);

return {
id: mid,
args: modalInfo?.args,
visible: !!modalInfo?.visible,
keepMounted: !!modalInfo?.keepMounted,
show: showCallback,
hide: hideCallback,
remove: removeCallback,
resolve: resolveCallback,
reject: rejectCallback,
resolveHide,
};
return useMemo(
() => ({
id: mid,
args: modalInfo?.args,
visible: !!modalInfo?.visible,
keepMounted: !!modalInfo?.keepMounted,
show: showCallback,
hide: hideCallback,
remove: removeCallback,
resolve: resolveCallback,
reject: rejectCallback,
resolveHide,
}),
[
mid,
modalInfo?.args,
modalInfo?.visible,
modalInfo?.keepMounted,
showCallback,
hideCallback,
removeCallback,
resolveCallback,
rejectCallback,
resolveHide,
],
);
}
export const create = <P extends {}>(
Comp: React.ComponentType<P>,
Expand Down

0 comments on commit 65dee75

Please sign in to comment.