I have two components (parent and child).
I want to send a parameter to parent component, it works but with a slight delay.
Parent component:
const [isMove, setMove] = useState(true);
return (
<ResponsiveGridLayout
cols={cols}
layouts={layouts}
className='layout'
isResizable={false}
isDraggable={isMove}
compactType='horizontal'
rowHeight={200}
measureBeforeMount
>
{picture.map((widget, index) => {
return (
<div key={index.toString()} className='card'>
// "isMove" should forbid element from moving
<Header widget={widget} isMove={setMove} />
</div>
);
})}
</ResponsiveGridLayout>
);
Child:
const Pen = ({isMove}) => {
function onClickByPen(event){
isMove(false);
};
return(
<div>
<button type='button' onMouseDown={onClickByPen}>
Tets
</button>
<div>
)
};
How do I send a parameter instantly?
When I press the button and move the mouse, the function forbiding does not have time to work.