Skip to content

Commit 45ae091

Browse files
authored
2.4.0 Release (#168)
Co-authored-by: Alex Nicholson <alex.n@clove.kitchen>
1 parent 2ea8f6e commit 45ae091

14 files changed

Lines changed: 110 additions & 38 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const App = () => {
3939
const questionDialog = useDialog(QuestionDialog);
4040

4141
const handleClick = async () => {
42-
const response = await questionDialog.show({
42+
const response = await questionDialog.open({
4343
// pass data to the dialog
4444
question: "Do you like apples?"
4545
});
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Deprecating show/hide in favour of open/close
3+
description: Notice for a breaking change in the next major release
4+
tags: [Other]
5+
---
6+
7+
As of the next major release (3.0.0), the `show()` and `hide()` methods of `useDialog()` will be deprecated in favour of `open()` and `close()`. There is currently no set date for this release, but we wanted to give you a heads up so you can migrate ahead of time
8+
<!-- truncate -->
9+
10+
## Why?
11+
The naming of "show" and "hide" imply that the dialog always exists, and is just being shown and hidden. This is misleading, and doesn't accurately reflect how the library works. Dialogs are created and destroyed every time they're opened, ensuring that they have clean state to prevent issues with stale state that arise especially when using forms or other stateful components within dialogs.
12+
13+
## What do I need to do?
14+
15+
Nothing, yet. There is no set date for the next major release, and it will likely be some number of months away. That being said, you can start migrating your code now, as the new methods are already available in the current version of the library and follow the exact same API & implementation as the old methods.
16+
17+
```tsx
18+
const myDialog = useDialog(MyDialog);
19+
20+
// Replace this
21+
await myDialog.show(...);
22+
await myDialog.hide();
23+
24+
// With this
25+
await myDialog.open(...);
26+
await myDialog.close();
27+
```
28+
29+
---
30+
31+
Feedback or ideas? We'd love to hear them! Open an issue over on [GitHub](https://github.com/a16n-dev/react-dialog-async/issues).
32+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: V2.4.0 has been released
3+
description: Release notes for version 2.4.0
4+
tags: [Release, Minor Release]
5+
---
6+
7+
Version 2.4.0 for React Dialog Async has been released 🎉
8+
<!-- truncate -->
9+
10+
## What's new?
11+
* Dialog components are now passed a `focused` prop. This is a boolean indicating if the dialog is "focused" or not. This is useful for handling cases where multiple dialogs are open at the same time.
12+
* Added deprecation warnings for `show()` and `hide()` methods on `useDialog()`. These methods will be removed in the next major release. [Read more here](/blog/2025/08/19/deprecating-show-hide)
13+
* Added a deprecation warning for the `mounted` prop passed to dialog components. This prop will be removed in the next major release
14+
---
15+
16+
Feedback or ideas? We'd love to hear them! Open an issue over on [GitHub](https://github.com/a16n-dev/react-dialog-async/issues).
17+

docs/docs/API/use-dialog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A hook that takes in a dialog component and then returns methods for interacting
1313
const exampleDialog = useDialog(ExampleDialog);
1414

1515
const onClick = async () => {
16-
await exampleDialog.show();
16+
await exampleDialog.open();
1717
}
1818
```
1919

@@ -30,7 +30,7 @@ const myDialog = useDialog(MyDialog, {
3030

3131
Available options are:
3232

33-
* `defaultData` - Default data to pass to the dialog component. Specifying this makes passing data to `.show()` optional, but data passed to `.show()` will still override the default data.
33+
* `defaultData` - Default data to pass to the dialog component. Specifying this makes passing data to `.open()` optional, but data passed to `.show()` will still override the default data.
3434
* `unmountDelayInMs` - Specify a delay in milliseconds to wait before unmounting the dialog component after it is closed. See the [animations](/animations) section for more information.
3535
* `customKey` - By default, only one instance of a dialog component is stored internally, regardless of how many places it is used with `useDialog`. If this behaviour is not desired, a `customKey` can be specified to create a new instance of the dialog component.
3636
* `hideOnHookUnmount` - If set to false, the dialog will not be hidden when the hook is unmounted. This can be useful if you want to open a dialog from a component that is short-lived, like a toast or tooltip.

docs/docs/basics/intro.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function MyComponent() {
5151
const dialog = useDialog(MyDialog);
5252

5353
return (
54-
<button onClick={() => dialog.show()}>
54+
<button onClick={() => dialog.open()}>
5555
Show dialog
5656
</button>
5757
);

docs/docs/basics/typescript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ If you use the above dialog, you'll notice the result returned is of type `boole
2929

3030
```tsx
3131
// result has type "boolean | undefined"
32-
const result = await confirmationDialog.show('Are you sure?');
32+
const result = await confirmationDialog.open('Are you sure?');
3333
```
3434
This is because we can never be sure the dialog is closed with a result, and you should always handle this case in your code.
3535

docs/docs/guides/alert-dialog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function Page() {
4343

4444
const handleClick = async () => {
4545
// Data will be passed to props.data in the dialog
46-
await alertDialog.show({
46+
await alertDialog.open({
4747
title: 'Alert',
4848
message: 'Hello, world!'
4949
});

docs/docs/guides/confirmation-dialog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function Page() {
4040
const confirmationDialog = useDialog(ConfirmationDialog);
4141

4242
const handleClick = async () => {
43-
const response = await confirmationDialog.show('Are you sure?');
43+
const response = await confirmationDialog.open('Are you sure?');
4444

4545
if(response === undefined) {
4646
console.log('Userclosed the dialog')

docs/docs/guides/first-dialog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function Page() {
3737
const simpleDialog = useDialog(SimpleDialog);
3838

3939
const handleClick = async () => {
40-
await simpleDialog.show();
40+
await simpleDialog.open();
4141

4242
// This code will run after the dialog is closed
4343
console.log('User closed the dialog');

packages/react-dialog-async/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "react-dialog-async",
33
"description": "A promise-based way to show dialogs in React",
44
"type": "module",
5-
"version": "2.3.2",
5+
"version": "2.4.0",
66
"sideEffects": false,
77
"main": "index.js",
88
"module": "index.esm.js",

0 commit comments

Comments
 (0)