Introduction to ReactJs 18-02-2017
React? ● JavaScript library for building UI ● created by Facebook ● “view” in MVC. ● Best Suitable for Dynamic Websites(ex: chat application)
Used By
Component
React ● Automatically updates your View after data changes. ● Render(Representation of view)
Virtual Dom
Virtual Dom(Diffing alg)
Create React APP: npm install -g create-react-app create-react-app hello-world cd hello-world npm start
First Component import React, { Component } from 'react'; class FirstComponent extends Component { render() { return ( <div className="firstComponent"> Hello, World! </div> ); } }
Props
Props class PropsExample extends Component { alertmessage(){ alert('Hi, Test alert') } render() { return ( <button class="ActionButton" onClick={this.alertmessage}> <span>{this.props.buttontext}</span> </button> ); } } // Usage: <PropsExample buttontext=”RSVP”>
State
State: class StateExample extends Component { constructor(props) { super(props); this.state = { count: 0 }; } Add(){ this.setState({count: this.state.count + 1}) } render() { return ( <h1>{this.state.count}</h1> <button class="ActionButton" onClick={this.Add}> <span>+(Add)</span> </button> ); } }
Component Life Cycle.
Meetup Code Examples https://github.com/ravigadila/learn-react/tree/master/meetup/18_02_2017
Micro Pyramid Micropyramid.com Blog: micropyramid.com/blog Forum: micropyramid.com/forum/ GitHub: https://github.com/MicroPyramid/ Facebook: https://www.facebook.com/MicroPyramid/ Twitter: https://twitter.com/MicroPyramid

Introduction to react_js