Course Content
React JSX
React JSX (JavaScript XML) is a syntax extension for JavaScript that allows you to write HTML-like code within JavaScript. JSX makes it easier to create React components and define their structure in a more readable and declarative way.
0/1
Components in React
In React.js, components are the building blocks of a React application. They allow you to break the UI into independent, reusable pieces and think about each piece in isolation. Here's an overview of components in React:
0/1
Props in React
Props (short for properties) are a way to pass data from a parent component to a child component in React. They are read-only and cannot be modified by the child component, ensuring a unidirectional data flow.
0/1
React Events
Just like HTML DOM events, React can perform actions based on user events.React has the same events as HTML: click, change, mouseover etc.
0/1
React Conditional Rendering
0/1
React Lists
0/1
React Forms
0/1
Styling React Using CSS
0/1
React Router
0/1
React Js
About Lesson

React Forms:

In React functional components, we use the useState hook to manage form input and note storage. Below is an example of handling forms in a notes application using functional components.

Example:

import React, { useState } from "react";
JavaScript
function NotesApp() {
  const [note, setNote] = useState(""); // State for input field
  const [notes, setNotes] = useState([]); // State for storing notes

  const handleChange = (event) => {
    setNote(event.target.value);
  };

  const handleSubmit = (event) => {
    event.preventDefault();
    if (note.trim() !== "") {
      setNotes([...notes, note]); // Add new note to list
      setNote(""); // Clear input field
    }
  };

  return (
    <div>
      <h2>Notes App</h2>
      <form onSubmit={handleSubmit}>
        <input
          type="text"
          value={note}
          onChange={handleChange}
          placeholder="Enter a note"
        />
        <button type="submit">Add Note</button>
      </form>
      
      <h3>My Notes</h3>
      <ul>
        {notes.map((note, index) => (
          <li key={index}>{note}</li>
        ))}
      </ul>
    </div>
  );
}
export default NotesApp;
JavaScript
const [formData, setFormData] = useState({ title: "", content: "" });<br><br>const handleChange = (event) => {<br>  setFormData({ ...formData, [event.target.name]: event.target.value });<br>};<br>