getInitialState() is life cycle method of a ReactJS component. The state can be updated using
setState() method.This method takes an JavaScript object. In this demo, “
We will learn how to create a initial state object and how to change the value of the state”. Below
code contains a react component having two
buttons and a
text string.The default color of the
applyState is red.When user click these button the state value gets change to blue and vice verse.<!doctype html>
<html lang="en">...
Published on December 18, 2014 09:31