Overview of React JS
Introduction:
React JS will be used within the development of single-page applications and mobile applications. It aims primarily to supply speed, simplicity, and measurability. As a programme library, react is usually used in conjunction with different libraries like Redux. It will be used with a mixture of other JavaScript libraries or frameworks, like Angular JS in MVC.
React was engendered by Jordan Walke, a programmer at Facebook. On April 18, 2017, Facebook publicized React Fiber associated with a new core algorithm program of the React framework library for building user interfaces. React Fiber can become the substratum of any future enhancements and have a development of the React framework. React was initially deployed on Facebook’s newsfeed in 2011 and on Instagram.com in 2012. The latest version of React JS is 16.4. It had been published on May 23, 2018.
ReactJS Features:
Let us take a lot of proximate look at some important features of React.
- JSX: JSX is a JavaScript syntax extension. It’s not necessary to use JSX in React development however, it is suggested.
- Components: React is all concerning elements. you would like to think about everything as a part. this may assist you to keep up the code once performing on larger scale projects.
- Unidirectional knowledge flow and Flux: React implements a technique knowledge flow that makes it simple to reason concerning your app. Flux is the architecture that is using Uni-directional data flow.
- License: React is accredited under Facebook Inc. Documentation is accredited under CC-BY 4.0.
Benefits of ReactJS:
1. Fast Learning Curve
React is incredibly a straightforward and light-weight library that solely deals with the view layer. It’s not a beast like other MV* frameworks like Angular or Ember. Any JavaScript developer will perceive the fundamentals and begin developing an awesome web application after only a few days of reading tutorial. The React guide says ‘Thinking in React’ may even be a touch different than you are accustomed to since it brings a new approach to the table, but it will become a lot easier and natural as you gain expertise with it.
2. Reusable Components
React provides an element-based structure. Elements are your Lego pieces. You begin with little parts like buttons, checkboxes, dropdowns etc. and therefore you produce wrapper parts composed of these smaller parts then you write higher-level wrapper parts. And, it goes on like that till you have got this one root elements which element is your app. Each component decides how it should be rendered. Every component has its own internal logic. This approach has some wonderful results. You will be able to re-use parts anywhere you would like. As a result, (1) your app has a consistent look and feel, (2) code reuse makes it easier to keep up and grow your codebase, and (3) it is easier to develop your app. This element-based mostly structure helped us tremendously in building our large web app.
3. Testability
ReactJS applications are super easy to test. React views are treated as functions of the state, thus we will manipulate the state we tend to pass to the Reacjs view and take a glance at the output and triggered actions, events, functions, etc.
Environment Setup:
NodeJS and NPM: NodeJS is the platform required for ReactJS development.
- npm install -g babel
- npm install -g babel-cli (Install babel)
- mkdir reactApp (Create root folder)
- npm init –f (Create package.json)
- Add Dependencies:
- npm install webpack –save
- npm install webpack-dev-server –save
- npm install react –save
- npm install react-dom –save
- Install Babel Plugins
- npm install babel-core
- npm install babel-loader
- npm install babel-preset-react
- npm install babel-preset-es2015
Create a Simple Application:
- npm install –g create-react-app
- create-react-app hello-world(appName)
- Cd appName
- npm start
- You would need to have the latest version(October 2017 (version 1.18)) of VS Code and VS Code Chrome Debugger Extension installed.
- https://code.visualstudio.com/
- https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome
- https://fb.me/react-devtools
- Dependency to format code automatically
- npm install –save husky lint-staged prettier
- husky makes it easy to use githooks as if they are npm scripts.
- lint-staged allows us to run scripts on staged files in git. See this
- blog post about lint-staged to learn more about it.
- prettier is the JavaScript formatter we will run before commits.
- npm install –save react-router