How do you test a component that depends on an API?
Control the network boundary and test loading, success, empty, and failure states through visible behavior.
The question library
Explore practical questions, clear explanations, and code examples across developer technologies.
Showing 3169–3180 of 3610 questions
Control the network boundary and test loading, success, empty, and failure states through visible behavior.
They manage server-state fetching, caching, deduplication, retries, background refresh, and invalidation.
Use a trusted authentication flow and protect server APIs independently of client UI checks; prefer secure server-side session handling where appro...
React escapes text rendered through normal JSX, but unsafe HTML insertion and other DOM sinks can still create XSS risks.
Micro-frontends split a frontend into independently developed or deployed parts integrated into a larger experience.
Measure bundle costs, split routes, optimize assets, reduce blocking work, and consider server rendering or static generation when appropriate.
CSR builds much of the UI in the browser; SSR produces HTML per request; SSG produces HTML ahead of requests.
Use a discriminated union such as loading, success with data, and error with an error value so each state contains only valid fields.
An effect may update state that changes one of its dependencies, causing the effect to run repeatedly.
Use functional updates such as setCount(previous => previous + 1) when the next value depends on the previous state.
State colocation keeps state near the components that use it, reducing coupling and unnecessary broad updates.
Cancel obsolete requests or track request identities and apply results only for the latest query.