I am trying to create a modal that will have a + / - counter.
However, I think since the state is in base component, modal is not able to recognize it. Any idea how to solve it?
I tried passing it as a prop but no luck
export default function ProgramCard() {
const [count, setCount] = useState(0);
const handleIncrement = () => {
console.log(1)
setCount(prevCount => prevCount + 1);
};
const handleDecrement = () => {
setCount(prevCount => prevCount - 1);
};
const [opened, { open, close }] = useDisclosure(false);
const openModal = () => modals.openConfirmModal({
title: 'Input Data',
children: (
<div>
<Button placeholder='-' onClick={handleDecrement}></Button>{" # "}{count}{" # "}
<Button placeholder='+' onClick={handleIncrement}></Button>
</div>
),
labels: { confirm: 'Confirm', cancel: 'Cancel' },
onCancel: () => console.log('Cancel'),
onConfirm: () => notifications.show({
title: 'Input Submitted',
message: 'Complete',
}),
});
return (
<Grid.Col span={2}>
<Paper shadow="xs" radius="md" p="sm">
<Text fw={700}>Sample</Text>
<br></br>
<Space h="xs" />
<Button variant={'light'} radius="xl" size="xs" onClick={openModal}>
Record
</Button>
</Paper>
<Modal opened={opened} onClose={close} title="Data Input" centered>
<Checkbox.Group
defaultValue={['react']}
label="Please select the prompt"
description="Select"
withAsterisk
>
<Group mt="xs">
<Checkbox value="react" label="React" />
<Checkbox value="svelte" label="Svelte" />
</Group>
</Checkbox.Group>
</Modal>
</Grid.Col>
)
}
I tried passing it as a prop but no luck