Skip to main content

React 

              -Is a java script library for build user interfaces.


              -Used to create single page applications.


              -Allows us to create reusable UI components.


              -Every component in react goes through a life cycle of  events.


              -Developed and maintained by Facebook and Instagram.


              -Acts as view in MVC architecture.


              -Classes are considered as components.


              -Simplicity and aim to performance are main benefits.





                                            Main features in React


(01)One way data flow

Data flows parent component to child component only.

But action flows from child component to parent component only.



(02)Virtual DOM

React maintain a virtual DOM.

Continuously monitoring users actions.

Only the changed element re enter.



(03)JSX

JavaScript XML.

HTML like syntax.

Prevents cross site attacks.



--------------------------------------------------------------------------------------------------------------------------


                     How to print "Hello World" using React


class Test extends React.component{
           render(){
                     return <h1>  Hello World  </h1>;
           }
}


--------------------------------------------------------------------------------------------------------------------------



              How to setup React Environment to the machine


In terminal type and run those commands.

C:\Users\Your Name>npm install -g create-react-app





Give a project name (In here 'myfirstreact' is the project name).

C:\Users\Your Name>npx create-react-app myfirstreact





Run bellow command to move to the project directory.

C:\Users\Your Name>cd myfirstreact






Run this command to execute the react application.

C:\Users\Your Name\myfirstreact>npm start





Then new window will open in browser with newly created React application.
If it does not open, we want to type localhost:3000 in the browser and get the application.





Small React form 

class MyForm extends React.Component {
  render() {
    return (
      <form>
        <h1>Hello</h1>
        <p>Enter your name:</p>
        <input
          type="text"
        />
      </form>
    );
  }
}
ReactDOM.render(<MyForm />, document.getElementById('root'));



                                       React Components



Components are reusable and independent bits of code. There are two types of components.

                                            (01).Class components

                                            (02).Function components.


Component name must be start with an upper case letter. As well component has to include extends React.Component statement.

The component also use render() method







Comments

Popular posts from this blog

GitHub link  https://github.com/chamoddissanayake/OnlineFashionStore Group Project - Online Fashion Store There is a use case diagram of the system . This diagram denotes a better understanding about the system online fashion store. It provides who are the users of the system and what are the functionalities of the each user. System Functionalities Main Roles in the system. User Admin Store Manager Guest Only users who logged in to the system can place orders   Once the admin creates a login for the store manager, it should be notified to the store manager via email Admin can create categories for the products The store manager can add products with details to the relevant category and add discounts to selected products User can add products to the shopping cart   Users can purchase the selected products in the shopping cart by selecting the payment method Users can c...
GitHub Guide https://guides.github.com/activities/hello-world/ Git development began in April 2005 Git is a distributed version-control system  It is designed for coordinating work among programmers It is primarily  used  for source code management in software development One of the biggest advantages of Git is its branching capabilities This facilitates the feature branch workflow popular with many Git users Advantages in Git Data redundancy and replication High availability Only one.git directory per repository Superior disk utilization and network performance Collaboration friendly Any sort of projects can use GIT Disadvantages in Git Git is less preferred for handling extremely large files or frequently changing binary files . GIT does not support ‘commits’ across multiple branches or tags. Git Commands  1) git config Utility : To set your user name and email in the main configura...
ExpressJS                   - Is a web application framework for Nodejs                   - Discharged as free and open source computer program                              under the MIT Permit                   - Is outlined for building web applications and APIs                   - Provides a robust set of features for web and mobile                                     applications                   - Developed ans maintained by the Node js foundation                   - High performance, extensible and reusable   Ho w to ...