Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modal options across open modal calls #60

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"modal",
"useModal"
],
"version": "0.2.1",
"version": "0.2.2",
"main": "lib/index",
"types": "lib",
"files": [
Expand Down
10 changes: 5 additions & 5 deletions src/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const ModalProvider: React.FC<ModalProviderProps> = ({
const showModal = useCallback(
(content: React.ReactNode, options?: Partial<ModalProps>) => {
setContent(content);
if (options) optionsRef.current = options;
optionsRef.current = options;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay to assign falsy values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could be undefined in that case. which is fine.

},
[],
);
Expand All @@ -47,10 +47,10 @@ export const ModalProvider: React.FC<ModalProviderProps> = ({
setContent(null);
}, []);

const value = useMemo(() => ({ showModal, closeModal }), [
showModal,
closeModal,
]);
const value = useMemo(
() => ({ showModal, closeModal }),
[showModal, closeModal],
);

return (
<ModalContext.Provider value={value}>
Expand Down