Skip to content

Instantly share code, notes, and snippets.

@VivekSaha
VivekSaha / App.jsx
Created September 2, 2025 10:28
React - JSX with Map Function Example
const App = () => {
const usersData = [
{sno: 1, name: 'Raj', age: 30, address: 'Delhi'},
{sno: 2, name: 'Lov', age: 39, address: 'Kolkata'},
{sno: 3, name: 'Amrit', age: 30, address: 'Ranchi'},
{sno: 4, name: 'luckey', age: 40, address: 'Patna'},
{sno: 5, name: 'Vikram', age: 34, address: 'Pune'}
]
return(
<>
@VivekSaha
VivekSaha / App.jsx
Created September 2, 2025 10:14
React - Select Option Example
import { useState } from "react"
const App = () => {
const [city, setCity] = useState('Kolkata');
const handleSelect = (e) => {
setCity(e.target.value);
}
return(
<>
<h1>Select Option in React</h1>
@VivekSaha
VivekSaha / App.jsx
Created September 2, 2025 10:08
React - Radio Option Example
import { useState } from "react"
const App = () => {
const [gender, setGender] = useState('Female');
const handleGender = (e) => {
setGender(e.target.value)
}
return(
<>
<h1>Radio Option in React</h1>
@VivekSaha
VivekSaha / App.jsx
Created September 2, 2025 08:49
React - Handle Checkbox Example
import { useState } from "react"
const App = () => {
const [skills, setSkills] = useState([]);
const handleSkills = (e) => {
if(e.target.checked){
setSkills([...skills, e.target.value]);
} else {
setSkills([...skills.filter((item)=>{
if(item!=e.target.value){
@VivekSaha
VivekSaha / App.jsx
Created September 2, 2025 08:30
React - Handle Input Field Example
import { useState } from "react"
const App = () => {
const [name, setName] = useState();
const [password, setPassword] = useState();
const handleName = (e) => {
setName(e.target.value);
}
const handlePass = (e) => {
setPassword(e.target.value);
@VivekSaha
VivekSaha / App.jsx
Created September 2, 2025 08:12
React - Props Passing Function Example
import User from "./Components/User"
const App = () => {
const myFun = (name) => {
alert(`Hello ${name}, How are you.`);
}
return(
<>
<h1>Props Passing Function in React</h1>
<User myFun={myFun} name="Raj"/>
@VivekSaha
VivekSaha / App.jsx
Created September 2, 2025 08:05
React - Props JSX Example
import User from "./Components/User"
const App = () => {
return(
<>
<h1>Props JSX in React</h1>
<User color='green'>
<h2>Raj</h2>
<p>33</p>
</User>
<User>
@VivekSaha
VivekSaha / App.jsx
Created September 2, 2025 07:58
React - Props Default Example
import User from "./Components/User"
const App = () => {
const age = 30;
return(
<>
<h1>Props Default in React</h1>
<User age={age}/>
</>
)
}
@VivekSaha
VivekSaha / App.jsx
Created September 2, 2025 07:52
React - Props De-structuring Example
import User from "./Components/User"
const App = () => {
const myName = "Raj"
const age = 30;
return(
<>
<h1>Props De-structuring in React</h1>
<User myName={myName} age={age}/>
</>
)
@VivekSaha
VivekSaha / App.jsx
Created September 2, 2025 07:49
React - Props Basic Example
import User from "./Components/User"
const App = () => {
return(
<>
<h1>Props Basic in React</h1>
<User myName="Raj" age="30"/>
</>
)
}
export default App