Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.
Solved

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

Sachin__
Excursionist
20 2 9

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 : []);
Accepted Solution (1)

Sachin__
Excursionist
20 2 9

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,
  });

View solution in original post

Replies 2 (2)

Sachin__
Excursionist
20 2 9

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,
  });

Mesto
Visitor
1 0 0

Can I ask that products.node.id is a list of id?