Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ props details:
<thead>
<tr>
<th style="width: 100px;">name</th>
<th style="width: 50px;">type</th>
<th style="width: 200px;">type</th>
<th style="width: 50px;">default</th>
<th>description</th>
</tr>
Expand Down Expand Up @@ -129,8 +129,8 @@ props details:
</tr>
<tr>
<td>duration</td>
<td>number</td>
<td>1.5</td>
<td>number | false</td>
<td>4.5</td>
<td>after duration of time, this notice will disappear.(seconds)</td>
</tr>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions src/Notice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Notify = React.forwardRef<HTMLDivElement, NoticeProps & { times?: number }
const [percent, setPercent] = React.useState(0);
const [spentTime, setSpentTime] = React.useState(0);
const mergedHovering = forcedHovering || hovering;
const mergedShowProgress = duration > 0 && showProgress;
const mergedShowProgress = duration && showProgress;

// ======================== Close =========================
const onInternalClose = () => {
Expand All @@ -53,7 +53,7 @@ const Notify = React.forwardRef<HTMLDivElement, NoticeProps & { times?: number }

// ======================== Effect ========================
React.useEffect(() => {
if (!mergedHovering && duration > 0) {
if (!mergedHovering && duration) {
const start = Date.now() - spentTime;
const timeout = setTimeout(
() => {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface NotificationConfig {
| boolean
| ({ closeIcon?: React.ReactNode; onClose?: VoidFunction } & React.AriaAttributes);
maxCount?: number;
duration?: number;
duration?: number | false;
showProgress?: boolean;
pauseOnHover?: boolean;
/** @private. Config for notification holder style. Safe to remove if refactor */
Expand Down
4 changes: 2 additions & 2 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type NoticeSemanticProps = 'wrapper';

export interface NoticeConfig {
content?: React.ReactNode;
duration?: number | null;
duration?: number | false;
showProgress?: boolean;
pauseOnHover?: boolean;

Expand All @@ -32,7 +32,7 @@ export interface OpenConfig extends NoticeConfig {
key: React.Key;
placement?: Placement;
content?: React.ReactNode;
duration?: number | null;
duration?: number | false;
}

export type InnerOpenConfig = OpenConfig & { times?: number };
Expand Down
8 changes: 4 additions & 4 deletions tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('Notification.Basic', () => {
</p>
),
key,
duration: null,
duration: false,
});
});

Expand Down Expand Up @@ -192,7 +192,7 @@ describe('Notification.Basic', () => {
{notUpdatableValue}
</p>
),
duration: null,
duration: false,
});
});

Expand All @@ -204,7 +204,7 @@ describe('Notification.Basic', () => {
</p>
),
key,
duration: null,
duration: false,
});
});

Expand Down Expand Up @@ -490,7 +490,7 @@ describe('Notification.Basic', () => {
</p>
),
key,
duration: null,
duration: false,
onClick: () => {
clicked += 1;
},
Expand Down
4 changes: 2 additions & 2 deletions tests/stack.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('stack', () => {
onClick={() => {
api.open({
content: <div className="context-content">Test</div>,
duration: null,
duration: false,
});
}}
/>
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('stack', () => {
onClick={() => {
api.open({
content: <div className="context-content">Test</div>,
duration: null,
duration: false,
closable: true,
});
}}
Expand Down