Coder Social home page Coder Social logo

todo-frontend-reactjs's Introduction

Frontend for Todo App

Setup

  1. Create a new React App Using - npx create-react-app new-app

  2. Navigate to the App project directory - cd new-app

  3. In the project directory, you can run:

npm install

Installs the necessary dependencies

npm start

Runs the app in the development mode.

Open http://localhost:3000 to view it in your browser if it does not automatically open on the 'npm start' command.

Notes

React JS Introduction

Components

A Component is the core building block of a React application. These are independent and reusable bits of code. Each component exists in the same space, but they work independently from one another and merge all in a parent component, which will be the final UI of your application.

States

React components have a built-in state object. The state object is where you store property values that belongs to the component. When the state object changes, the component re-renders.

Props

Props stand for "Properties." It is an object which stores the values of attributes of a tag and work similar to the HTML attributes. It gives a way to pass data from one component to other components. Props are passed to the component in the same way as arguments passed in a function.

React Hooks

Hooks allows you to use state and other React features without writing a class. Hooks are the functions which "hook into" react states from function components. This allows us to manage component's state or perform an after effect when certain changes occur in state(s) without writing a class.

useState

The React useState Hook allows us to track state in a function component. State generally refers to data or properties that need to be tracking in an application.

useState accepts an initial state and returns two values:
const [stateVariable, setStateVariableFunction] = useSate(initialState)

useEffect

The useEffect Hook allows you to perform side effects in your components. Some examples of side effects are: fetching data, directly updating the DOM, and timers.

useEffect accepts two arguments:
useEffect(function, dependency_list)

useRef

The useRef Hook allows you to persist values between renders. It can be used to store a mutable value that does not cause a re-render when updated.

It is generally used to map to the value of a HTML element like below:
const inputText = useRef()
<input type="text" ref="inputText"/>

To retrieve the value of the input element at any given point, use:
const retrievedValue = inputText.current.value

Advances JS

Array de-structuring

We may have an array or object that we are working with, but we only need some of the items contained in these. De-structuring makes it easy to extract only what is needed.

Example:

const vehicles= [‘Mustang’ , ‘f-150’, ‘Expedition’];
const [car, truck, suv] = vehicles;

So, here variables car = 'Mustang', truck = 'f-150' and suv = 'Expedition'

Spread Operator

The JavaScript spread operator (...) allows us to quickly copy all or part of an existing array or object into another array or object respectively.\

Example:

Arrays
const array1 = [1, 2, 3];
const array2 = [4, 5, 6];
const finalArray = […array1, …array2]; => [1,2,3,4,5,6]

Objects
const object1 = {'name':'xyz', id: 1}
const object2 = {'age': 50}
const finalObject = {...object1, ...Object2}; => {'name':'xyz','id':1,'age':50}

todo-frontend-reactjs's People

Contributors

rakshithalmk avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.