How to resourceIDResolver in IndexTable component of polaris i am not able to select in bulk .

Solved
Sachin__
Excursionist
20 2 1

Unhandled Runtime Error

Error: Your resource does not directly contain an id. Pass a ''resourceIDResolver" to "useIndexResourceState"

Sachin___0-1617879906791.png

 

on click i got this error 

Sachin___1-1617878993892.png

 

how use resourceIDResolver 

I am getting this error while i tried to select all product in table.

I am new in polaris please help.

 

 

i am setting product array like this id is inside the node but how to pass id directly by using this resourceIDResolver 

 setProducts(data.products.edges ? data.products.edges : []);
0 Likes
Sachin__
Excursionist
20 2 1

This is an accepted solution.

resourceIDResolver a function that returns id.

 

  const resourceIDResolver = (products) => {
    return products.node.id;
  };

  const {
    selectedResources,
    allResourcesSelected,
    handleSelectionChange,
  } = useIndexResourceState(products, {
    resourceIDResolver,
  });
0 Likes