Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
import { useState } from 'react'; import logo from './logo.svg'; import './App.css'; function App() { const [counter, setCounter] = useState(0); const handleClick = (operation = '+') => { if (operation === '-') { if (counter < 0) { throw new Error('Number is less than zero'); } setCounter((prevState) => (prevState -= 1)); return; } setCounter((prevState) => (prevState += 1)); }; return (
); } export default App;Edit
Learn React handleClick('-')}>-src/App.js
and save to reload.{counter}
handleClick()}>+
We will be creating a demo application using Create React App. To get started, open a terminal and run the code below: