I am making a Shopify app using Shopify Polaris. I used the ActionList component. https://polaris.shopify.com/components/actions/action-list
I want to change the state value on the onAction event. I did like this.
const [searchValue, setSearchValue] = useState('');
const handleAction = (value) => {
setSearchValue(value);
}
const a = ["A","B"];
const searchResultsMarkup = (
<ActionList
items={[
{
content: a[0],
onAction: handleAction(a[0]),
},
{
content: a[1],
onAction: handleAction(a[1]),
},
/>
);
I am a beginner in React. So maybe a silly question. but kindly teach me.
Thanks