Skip to content

Commit 2b9a821

Browse files
authored
Updating Toast label definition to be string (#5389)
1 parent dad13d5 commit 2b9a821

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/@react-spectrum/toast/src/Toast.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import InfoMedium from '@spectrum-icons/ui/InfoMedium';
1919
// @ts-ignore
2020
import intlMessages from '../intl/*.json';
2121
import {QueuedToast, ToastState} from '@react-stately/toast';
22-
import React, {ReactNode, useContext} from 'react';
22+
import React, {useContext} from 'react';
2323
import styles from '@adobe/spectrum-css-temp/components/toast/vars.css';
2424
import SuccessMedium from '@spectrum-icons/ui/SuccessMedium';
2525
import toastContainerStyles from './toastContainer.css';
@@ -28,9 +28,9 @@ import {useLocalizedStringFormatter} from '@react-aria/i18n';
2828
import {useToast} from '@react-aria/toast';
2929

3030
export interface SpectrumToastValue {
31-
children: ReactNode,
31+
children: string,
3232
variant: 'positive' | 'negative' | 'info' | 'neutral',
33-
actionLabel?: ReactNode,
33+
actionLabel?: string,
3434
onAction?: () => void,
3535
shouldCloseOnAction?: boolean
3636
}

packages/@react-spectrum/toast/src/ToastContainer.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
import {AriaToastRegionProps} from '@react-aria/toast';
14-
import React, {ReactElement, ReactNode, useEffect, useRef} from 'react';
14+
import React, {ReactElement, useEffect, useRef} from 'react';
1515
import {SpectrumToastValue, Toast} from './Toast';
1616
import {Toaster} from './Toaster';
1717
import {ToastOptions, ToastQueue, useToastQueue} from '@react-stately/toast';
@@ -21,7 +21,7 @@ export interface SpectrumToastContainerProps extends AriaToastRegionProps {}
2121

2222
export interface SpectrumToastOptions extends Omit<ToastOptions, 'priority'> {
2323
/** A label for the action button within the toast. */
24-
actionLabel?: ReactNode,
24+
actionLabel?: string,
2525
/** Handler that is called when the action button is pressed. */
2626
onAction?: () => void,
2727
/** Whether the toast should automatically close when an action is performed. */
@@ -119,7 +119,7 @@ export function ToastContainer(props: SpectrumToastContainerProps): ReactElement
119119
return null;
120120
}
121121

122-
function addToast(children: ReactNode, variant: SpectrumToastValue['variant'], options: SpectrumToastOptions = {}) {
122+
function addToast(children: string, variant: SpectrumToastValue['variant'], options: SpectrumToastOptions = {}) {
123123
// Dispatch a custom event so that toasts can be intercepted and re-targeted, e.g. when inside an iframe.
124124
if (typeof CustomEvent !== 'undefined' && typeof window !== 'undefined') {
125125
let event = new CustomEvent('react-spectrum-toast', {
@@ -157,19 +157,19 @@ function addToast(children: ReactNode, variant: SpectrumToastValue['variant'], o
157157

158158
const SpectrumToastQueue = {
159159
/** Queues a neutral toast. */
160-
neutral(children: ReactNode, options: SpectrumToastOptions = {}): CloseFunction {
160+
neutral(children: string, options: SpectrumToastOptions = {}): CloseFunction {
161161
return addToast(children, 'neutral', options);
162162
},
163163
/** Queues a positive toast. */
164-
positive(children: ReactNode, options: SpectrumToastOptions = {}): CloseFunction {
164+
positive(children: string, options: SpectrumToastOptions = {}): CloseFunction {
165165
return addToast(children, 'positive', options);
166166
},
167167
/** Queues a negative toast. */
168-
negative(children: ReactNode, options: SpectrumToastOptions = {}): CloseFunction {
168+
negative(children: string, options: SpectrumToastOptions = {}): CloseFunction {
169169
return addToast(children, 'negative', options);
170170
},
171171
/** Queues an informational toast. */
172-
info(children: ReactNode, options: SpectrumToastOptions = {}): CloseFunction {
172+
info(children: string, options: SpectrumToastOptions = {}): CloseFunction {
173173
return addToast(children, 'info', options);
174174
}
175175
};

0 commit comments

Comments
 (0)