juliancwirko / react-s-alert

Alerts / Notifications for React with rich configuration options
https://www.npmjs.com/package/react-s-alert
MIT License
649 stars 75 forks source link

Keep alert when redirect page. #57

Closed nghiepdev closed 6 years ago

nghiepdev commented 6 years ago

Hi guys,

After user login success, I did the following two things:

But redirect page has caused react-s-alert not working. Because the component has destroyed.

class Login extends React.Component {
...
 login = () => {
   apiLogin().then(() => {
    Alert.success('login success');
    return Router.push('/profile');
   })
 }
...

Thanks

juliancwirko commented 6 years ago

You can always put <Alert /> component somewhere in your layout, somewhere outside your app's content component. As close to the root component as possible. This should work.

nghiepdev commented 6 years ago

Thanks for your answer. I understand the problem. But I'm using Next.js, I cannot put <Alert /> to root component or near the root component.

MikeSha commented 5 years ago

Hey @nghiepit . Have you managed this issue?