score:1

Accepted answer
export const createNotification = () => {
  const container = document.getElementById("notificationContainer");
  console.log(container);
  return render(createPortal(<ToastNotification />, container), document.createElement("div"));
};

score:0

import { createNotification } from "../../helpers";

export const createNotification = () => {
    const container = document.getElementById("notificationContainer");
    console.log(container); //just to check function is running and has found container
    return createPortal(<ToastNotification />, container); //doesn't render anything in container
};

const Login = () => {
    const [validate, setValidate] = useState(false);
    
    const validateLogin = async (event) => {
        if('some logic')
            return setValidte(true)
        setVAlidte(false)
    };


    useEffect(() => {
        if(!valite)
            return;
        //axios heare
    }, [validate])
    // main component content
    
    
    return (
        <>
            {!validate && <CreateNotfication/>}
            <!-- validateLogin() called on form submit -->
        </>
    );
};


Related Query

More Query from same tag