Forms let users to interact with the web page.
Example Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import React, { useState } from 'react'; import ReactDOM from 'react-dom/client'; //App function component function App() { return ( <div> <p>This is a example of form in react.</p> <form> <label>Enter your name: <input type="text" /> </label> </form> </div> ); } const root = ReactDOM.createRoot(document.getElementById("root")); //creating a root React component in your application root.render(<App />) // rendering React components into a DOM node. |
Output:
