JSX
1. What is JSX?
2. JSX Syntax
<div> <div> <h1>Hello</h1> </div> <div> <h2>World</h2> </div> </div><div className='greeting'>Hello</div>function App() { const name = 'Ella Choi'; return <div>Hello, {name}!</div>; }function Hello() { return <div>Hello!</div>; } function HelloWorld() { return <Hello />; }<div> { (1+1 === 2) ? (<p>Correct</p>) : <p>Wrong</p>) } </div>const posts = [ { id: 1, title: 'Hello World', content: 'Welcome to learning React!' }, { id: 2, title: 'Installation', content: 'You can install React from npm' }, ]; function Blog() { const content = posts.map((post) => ( <div key={post.id}> <h3>{post.title}</h3> <p>{post.content}</p> </div> )); return <div>{content}</div>; }const Hello - () => { return ( [<div>Hello</div>, <div>Nice to meet you</div>] ) }
Last updated