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
Is your feature request related to a problem? Please describe.
The hook useBeforeUnload registers an event when a component that uses that hooks is rendered for the first time. The isDirty parameter can be a function but the message parameter currently is not. So the message is set once unless you rerender the component.
Describe the solution you'd like
I would like to suggest the following signature for useBeforeUnload
Describe alternatives you've considered
I've used a local state const [beforeUnloadMessage, setBeforeUnloadMessage] = useState(defaultMessage); but this caused the component to rerender only to display a different beforeUnloadMessage in case the user would navigate away.
Given that custom message is no longer supported by most browsers, should we just mark the message arg as @deprecated instead? Supporting function value and even asking the devs to provide any value does not seem worthy these days. The result won’t be seen by most users anyway.
Is your feature request related to a problem? Please describe.
The hook useBeforeUnload registers an event when a component that uses that hooks is rendered for the first time. The isDirty parameter can be a function but the message parameter currently is not. So the message is set once unless you rerender the component.
Describe the solution you'd like
I would like to suggest the following signature for useBeforeUnload
Describe alternatives you've considered
I've used a local state
const [beforeUnloadMessage, setBeforeUnloadMessage] = useState(defaultMessage);
but this caused the component to rerender only to display a different beforeUnloadMessage in case the user would navigate away.I can send you a PR for this.
Related to #842
The text was updated successfully, but these errors were encountered: