Skip to content
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

Merged
merged 2 commits into from
Mar 21, 2024

Conversation

simonguo
Copy link
Member

@simonguo simonguo commented Mar 20, 2024

Copy link

vercel bot commented Mar 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rsuite-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2024 3:13am
rsuite-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2024 3:13am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
rsuite-v4 ⬜️ Ignored (Inspect) Visit Preview Mar 21, 2024 3:13am

Copy link

codesandbox-ci bot commented Mar 20, 2024

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.

Copy link

codecov bot commented Mar 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.75%. Comparing base (524fc7a) to head (ff0e02b).

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           
Flag Coverage Δ
ChromeCi 93.71% <ø> (ø)
Firefox 93.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@acefei
Copy link

acefei commented Mar 29, 2024

Hi @simonguo, I'm wondering if this issue may be related to a regression. The custom toast doesn't close after the specified timeout.
image

@simonguo
Copy link
Member Author

simonguo commented Apr 2, 2024

Hi @acefei, automatically closing the toast requires calling onClose with a timeout in the custom toast.

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'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants