4IT580: Docs
4IT580 WebGitLab

2nd Theoretical Class:
Introduction to React




React

react.dev

Components

Component = function that returns JSX

React renders the component by calling the function.

Component names must start with a capital letter.

Composition

Resources:

JSX

JavaScript Syntax Extension

JavaScript in JSX:

Using curly braces: A window into the JavaScript world.

Any JavaScript expression will work inside the curly braces.

Resources:

Props

Special props

Reference:

Events

⚠️ Hint: When passing an event handler, do not call it immediately - only pass the reference to it!

Event handlers as props

Resources:

Hooks

Special React functions to store internal state, run side effects and more things from a component.

Hook names always start with followed by a capital letter.

State

A hook to store a state variable inside a component:

Components can have multiple state hooks

State is local to a component instance on the screen

Resources:

More about hooks