Ad

Adding Loading State On Button - Reactjs Shopify Polaris

- 1 answer

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

Ad

Answer

Change to

<Button primary onClick={this.handleSubmit} Loading={this.state.buttonloading}>Login</Button>
Ad
source: stackoverflow.com
Ad