Smith Steve
Smith Steve

Reputation: 161

How to display props or state in alert?

How to display props or state in alert box ? how to display it on alert box as we print on console.

 alert('Props',this.props);

Upvotes: 3

Views: 2144

Answers (2)

Sanket Meghani
Sanket Meghani

Reputation: 905

You need to use JSON.stringify to convert it to string.

alert('props: ' + JSON.stringify(this.props));

Upvotes: 1

Vossen
Vossen

Reputation: 162

Alert takes only one parameter. If you want to do something like that you should write:

alert('props' + this.props);

Upvotes: 3

Related Questions