Answer the question
In order to leave comments, you need to log in
How to make a pop up toast?
Hello
I want a message to pop up from the server in case of an error
Here is Tost
const [show, setShow] = useState(false);
<Toast onClose={() => setShow(false)} show={show} delay={3000} autohide>
<Toast.Body>text</Toast.Body>
</Toast>
import { useCallback, useState } from "react";
import { Toast } from "react-bootstrap";
export const useMessage = () => {
const [show, setShow] = useState(false);
return useCallback((text) => {
if (text) {
<Toast onClose={() => setShow(false)} show={show} delay={3000} autohide>
<Toast.Body>text</Toast.Body>
</Toast>
}
});
}
const message = useMessage();
useEffect(() => {
message(error);
clearError();
}, [error, message, clearError]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question