Question: So, I was working on commerce.js API. But when I press add to cart, it takes a bit of time to update the cart items number (from API) so I thought I should add a loading button until the cart items load. I found LoadingButton from **@mui/lab** so I used it. but the problem is even though that button is inside the loop when pressing onClick all the other button also goes to the loading state. IDK am I missing something or is my coding false?. Please check below & help me. Thanks. :)   

***Here is the main problem.***

[![material ui](https://i.stack.imgur.com/g3p6N.gif)](https://i.stack.imgur.com/g3p6N.gif)

Here is the app.js where you can see loading state & other API fetching  

[![enter image description here](https://i.stack.imgur.com/qEncG.png)](https://i.stack.imgur.com/qEncG.png)

products component in app.js. you can see I passed down the products & loading props   

[![enter image description here](https://i.stack.imgur.com/EKAbS.png)](https://i.stack.imgur.com/EKAbS.png)

products loop & props down to product component   

[![enter image description here](https://i.stack.imgur.com/yH4iW.png)](https://i.stack.imgur.com/yH4iW.png)

finally the cart loading button in the product component with loading props. it works but all other buttons also loads at the same time.   

[![enter image description here](https://i.stack.imgur.com/x908f.png)](https://i.stack.imgur.com/x908f.png)

Answer: 
It is not possible to use the value of a non-static member as default argument. You can use an overload instead:

```
struct S {
    int a;
    int func(int b) {
        // do something
    }
    int func() { return func(a); }
};

```
Another alternative is to use [`std::optional`](https://en.cppreference.com/w/cpp/utility/optional):

```
struct S {
    int a;
    int func(std::optional<int> ob = std::nullopt) {
        int b = ob.value_or(a);
        // do something
    }
};

```