Adding loading state on button - Reactjs Shopify Polaris

1.2k views Asked by At

I am trying to add loading state on button when user clicks login until login function return something.

Simple button is like:

<Button primary onClick={this.handleSubmit}></Button>

And loading button is like:

<Button primary onClick={this.handleSubmit} Loading></Button>

So i want to add Loading attribute into button when user clicks on it but i get error on following code:

Here is button code:

<Button primary onClick={this.handleSubmit} {this.state.buttonloading}>Login</Button>

Error:

Syntax error: Unexpected token, expected ... (64:61)
AT: <Button primary onClick={this.handleSubmit} {this.state.buttonloading}>Login</Button>
                                                ^

How I am suppose to add Loading attribute in Button component

PS. I am using Shopify Polaris Components

1

There are 1 answers

1
Giang Le On BEST ANSWER

Change to

<Button primary onClick={this.handleSubmit} Loading={this.state.buttonloading}>Login</Button>