0

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

Noman Ali
  • 3,160
  • 10
  • 43
  • 77

1 Answers1

2

Change to

<Button primary onClick={this.handleSubmit} Loading={this.state.buttonloading}>Login</Button>
Giang Le
  • 6,446
  • 4
  • 23
  • 26
  • "Loading" is called "props". In "Button " component it call "this.props.Loading", if true then set Loading in Component Button. They use short syntax "Loading" instead of Loading={true}. Sorry for my bad english – Giang Le Sep 14 '17 at 07:08