Cheatsheet - React

Yuvraj Patil
Mar 15, 2021

--

General

Create a React App with TypeScript template

npx create-react-app uv-app --template typescript

Functional Component

Event Handling

<button onClick={activateLasers}>
Activate Lasers
</button>

Render List

Option 1

{
students.map((obj: any, index: any) => (
<div key={index}> {obj.title} </div>
))
}

Option 2

{
[…Array(15)].map((obj: any, index: number) => (
<p>React is best</p>
))
}

Conditional rendering

Type 1: If statement style

{props.hasImage &&
<MyImage />
}

Type 2: If else statement style

{props.hasImage ?
<MyImage /> :
<OtherElement/>
}

Hooks

useState

useEffect

useSelector

Others

Memoization

A. Component

B. Function

API Call using Axios

Higher Order Components (HOC)

Context API

Routing with React-Router

Interface for React Component Props

Interface for React Native Component Props

Interface for React Component Props

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Yuvraj Patil
Yuvraj Patil

Written by Yuvraj Patil

Riding the dragon in realm of React Native. Website: https://.www.yuvrajpatil.com

No responses yet

Write a response