📄 Table of contents

Creating a Toolchain from Scratch

◉ Create-React-App

Why

What

Updates To create-react-app

Prerequisites

Nodejs/npm (install this first of all)$ npx install -g create-react-app. // yes its npx and not npm$ create-react-app — version$ create-react-app version: 1.4.3$ create-react-app new-project
# new-project is the directory where you want to develop your application. It takes some time over here to create the minimal basic folder structure.
$ cd new-project$ yarn start // or npm start
initial folder structure
Our default starter React project

Exploring Our First App

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

Wait, What Is JSX?

◉ Setting Up a Redux Project With Create-React-App

[1]. npm install -g create-react-app# Installs create-react-app globally[2]. create-react-app new-project.    #create a new project,
[3]. cd new-project
[4]. npm start
npx create-react-app redux-cra
cd redux-cra
npm start

A Glimpse of a CRA Project Folder Structure

Redux Setup

npm install redux react-redux redux-thunk --save

Action Creators

/*
src/actions/simpleAction.js
*/
export const simpleAction = () => dispatch => {
dispatch({
type: 'SIMPLE_ACTION',
payload: 'result_of_simple_action'
})
}

Reducers

/*
src/reducers/simpleReducer.js
*/
export default (state = {}, action) => {
switch (action.type) {
case 'SIMPLE_ACTION':
return {
result: action.payload
}
default:
return state
}
}

Provider Store

/*
src/index.js
*/
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux'
import configureStore from './store';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(
<Provider store={configureStore()}>
<App />
</Provider>,
document.getElementById('root')
);

registerServiceWorker();

Connect React Component to Store

export default connect()(App);
/*
src/App.js
*/
export default connect(mapStateToProps, mapDispatchToProps)(App);

Experience with Front-end Technologies and MERN / MEAN Stack. Working on all Major UI Frameworks like React, Angular.