Glossary
React Hooks
Functions such as useState and useEffect that give React function components state, side effects and reusable logic. Hooks replaced class components as the standard way to write React.
General definition
React Hooks are functions, all named with a use prefix, that let a function component tap into React features that once required a class: local state, lifecycle-style side effects, context and refs. They arrived in React 16.8 in 2019 and are now the default way to write React components. A hook is called at the top level of a component or of another hook, never inside loops or conditions, so React can track each call in the same order on every render.
The hooks most codebases use daily:
useStateanduseReducerfor local state.useEffectfor side effects that sync with something outside React, such as opening a socket or subscribing to an event.useContextto read values from a provider without prop drilling.useReffor mutable values and DOM nodes that should not trigger renders.useMemoanduseCallbackto skip recomputing values and recreating functions.useSyncExternalStoreto subscribe safely to a store that lives outside React.- React 19 additions:
usefor reading a promise or context,useActionStateanduseOptimisticfor form and optimistic UI flows.
A custom hook is any function that starts with use and calls other hooks. It is the main way to package stateful logic for reuse: a team might write useMessages(roomId) or useOnlineStatus() to hide subscriptions, caching and cleanup behind one call. In real-time UIs the effect cleanup function matters as much as the effect itself, because a chat component that mounts and unmounts must unsubscribe from the room or the connection leaks listeners. The React Compiler, released as stable in 2025, automates much of the memoisation that useMemo and useCallback used to require by hand.
In the Ethora ecosystem
The Ethora React chat component (@ethora/chat-component on npm, React 19 ready) is built with hooks internally and is designed to sit inside a hooks-based app. Rather than making you manage the XMPP connection, room subscriptions and message cache in your own effects, the Chat SDK for React owns that lifecycle and exposes configuration and callbacks so your app can respond to new messages, presence changes and typing activity, and pass in the current user, room and theme.
That split keeps your own components simple: you hold app-level state (who is signed in, which room is open) in your existing hooks or store and hand it down as props. Chat state that is expensive to get right, such as unread counts and the last message per room, is computed server-side by Ethora and delivered to the client, so a custom hook in your app does not need to replay history to work it out. See state management for how that fits with Redux, Zustand or context.