Loading...
By KarnatakaPUCS Team on 7/10/2026
React is a popular JavaScript library for building user interfaces. Learn how to create modern web applications with React.
bashnpx create-react-app my-app cd my-app npm start
jsxfunction Welcome({ name }) { return <h1>Hello, {name}!</h1>; }
jsximport { useState } from 'react'; function Counter() { const [count, setCount] = useState(0); return ( <div> <p>Count: {count}</p> <button onClick={() => setCount(count + 1)}> Increment </button> </div> ); }
Props pass data from parent to child:
jsxfunction UserCard({ user }) { return ( <div className="card"> <h2>{user.name}</h2> <p>{user.email}</p> </div> ); } // Usage <UserCard user={{ name: 'John', email: 'john@example.com' }} />
jsximport { useEffect, useState } from 'react'; function DataFetcher() { const [data, setData] = useState(null); useEffect(() => { fetch('/api/data') .then(res => res.json()) .then(data => setData(data)); }, []); return <div>{data ? JSON.stringify(data) : 'Loading...'}</div>; }