Reputation: 342
I have a modal that I want to open in useffect here is the my code in carvin function console.log working but modal didn't popup. I have made one main component as Loyaltycash and calling carvin in useeffect
import React, { useState, useEffect } from "react";
export default function Loyaltychash(props) {
const { show, handlemodalloyalty, contractid } = props;
useEffect(() => {
if (contractid != "") {
getdata();
setLoading(true);
carvin();
}
}, [show]);
return (
<div>
</div>
);
}
function carvin() {
console.log("innnn");
return (
<div>
<div>
<Modal show={true}>
<Modal.Header>
</Modal.Header>
<Modal.Body>
</Modal.Body>
<Modal.Footer>
<Button variant="secondary">Close</Button>
<Button variant="primary">Save Changes</Button>
</Modal.Footer>
</Modal>
</div>
</div>
);
}
Upvotes: 1
Views: 632
Reputation: 457
you are using show={true} for all time
<Modal show={show}>
and
return (
<div>
{carvin()}
</div>
);
Upvotes: 1