-
-
Notifications
You must be signed in to change notification settings - Fork 922
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: fix the problem that useToaster cannot be imported on demand and update the docs directory #3689
Conversation
… update the docs directory
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3689 +/- ##
=======================================
Coverage 93.75% 93.75%
=======================================
Files 637 637
Lines 22318 22318
Branches 3052 3052
=======================================
Hits 20925 20925
Misses 713 713
Partials 680 680
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Hi @simonguo, I'm wondering if this issue may be related to a regression. The custom toast doesn't close after the specified timeout. |
Hi @acefei, automatically closing the toast requires calling import React from 'react';
import { useToaster, ButtonToolbar, SelectPicker, Button } from 'rsuite';
const Toast = React.forwardRef((props, ref) => {
const { type, placement, duration, children, onClose, ...rest } = props;
+ React.useEffect(()=>{
+ setTimeout(onClose, duration);
+ },[]);
return (
<div
ref={ref}
{...rest}
style={{ padding: 10, background: '#fff', borderRadius: 4, marginTop: 10 }}
>
{children}
<hr />
<button onClick={onClose}>Close</button>
</div>
);
});
const App = () => {
const toaster = useToaster();
return (
<Button
onClick={() =>
toaster.push(
<Toast>
<h4>Custom Toast</h4>
<p>
This is a custom toast with a close button. You can also set the duration and
placement.
</p>
</Toast>,
{ placement: 'topCenter', duration: 5000 }
)
}
appearance="primary"
>
Push
</Button>
);
};
ReactDOM.render(<App />, document.getElementById('root')); |
https://rsuite-nextjs-git-fix-use-toaster-rsuite.vercel.app/components/toaster/