I have the following function component which renders 3 checkboxes (Shopify Polaris):
function CustomersList() {
const [selected, setSelected] = useState(['hidden']);
const handleChange = useCallback((value) => setSelected(value), []);
return (
<ChoiceList
allowMultiple
title="Customers:"
choices={[
{
label: 'Customer 1',
value: 'customer1',
},
{
label: 'Customer 2',
value: 'customer2',
},
{
label: 'Customer 3',
value: 'customer3',
}
]}
selected={selected}
onChange={handleChange}
/>
);
}
... and the same func. component is used in a parent component (both in same file):
class ParentComponent extends Component {
render() {
return (
<Page title="Title">
<Layout>
<Layout.Section>
<Card title="Customers" sectioned>
<CustomersList />
<Subheading>
Selected customers: {customer_value}
</Subheading>
</Card>
</Layout.Section>
</Layout>
</Page>
)
}
}
Now, my question is how to send and get the customer value (customer1, customer2, etc) from func. component to parent component, to show the value here: Selected customers: {customer_value}?
Thanks