Skip to main content
NostalgiaPHP
Home
About
  • Components
  • Blink
  • Fetch
  • Slider
  • REST API
BlogDoxSearchContact
Admin
  • Sitemap
  • Robots
GitHub
  1. Home
  2. Blog
  3. React in a Nutshell
Sep 2, 2025

React in a Nutshell

This page covers the essentials of React. A React component is simply a function that outputs HTML and manages its own state.

Counter.jsx

import { useState } from 'react'

const Counter = (props) => {
  const [count, setCount] = useState(0)

  // Callbacks
  const dec = prev => prev - 1
  const inc = prev => prev + 1
  const zero = () => 0

  return (
    <div>
      <p>The count is {count}, <strong>{props.word}</strong>.</p>
      <button onClick={() => setCount(dec)}>-</button>
      <button onClick={() => setCount(inc)}>+</button>
      <button onClick={() => setCount(zero)}>Reset</button>
    </div>
  )
}

export default Counter

App.jsx (the root component)

import Counter from './Counter.jsx'

const App = () => (
  <>
    <Counter word="first" />
    <Counter word="second" />
  </>
)

export default App

Explore

Recent Items

  • You Might Not Want to Use NostalgiaPHP
    Oct 8, 2025
  • Understanding the Styles
    Oct 5, 2025
  • Appear Animations
    Oct 2, 2025
  • Nosty CLI — Your New Best Friend
    Sep 28, 2025
  • Introducing the NostalgiaPHP REST API
    Sep 27, 2025

Tags

  • animation (1)
  • api (1)
  • blink (1)
  • css (1)
  • intersectionobserver (1)
  • js (1)
  • json (1)
  • nostalgia (2)
  • php (3)
  • reactivity (1)
  • rest (1)
  • retro (3)
  • simplicity (3)
  • slank (1)
© 2025 NostalgiaPHP. All rights reserved. ⬆ Back to Top