How Do You Render HTML Strings with dangerouslySetInnerHTML?
Use dangerouslySetInnerHTML with an __html object to render HTML strings in React. Learn why it is risky, how to sanitise input and what to use instead.
47 posts about React: questions with answers, tutorials and articles, newest first.
Use dangerouslySetInnerHTML with an __html object to render HTML strings in React. Learn why it is risky, how to sanitise input and what to use instead.
React may call your component any time and more than once, so rendering must be a pure calculation. See what breaks purity and where side effects should go.
The React component tree is the nested hierarchy of components in your app. See how React renders it, passes props down it and re-renders branches after state changes.
Use the React children prop to build wrapper and layout components, add extra slots with named props, and type children in TypeScript.
Pass an object with camelCase keys to the style prop to apply inline styles in React, and learn when CSS classes are the better choice.
JSX uses className because class is a reserved JavaScript word. Learn how to build dynamic class lists and other renamed attributes.
React fragments return several elements without an extra wrapper node. Learn the short and keyed forms and when to use them.
Use default and named exports to share React components between files, and fix the usual import errors with correct paths.
Create a React function component with a capitalised function that returns JSX, then use it like an HTML tag and give it props.
Use curly braces to put variables, function calls, conditions and lists inside JSX, and learn which values React renders or rejects.
The core JSX rules explained with fixes for the errors beginners hit: single root, closed tags, className, curly braces and component names.
JSX is JavaScript syntax that looks like HTML. See how it compiles to function calls, what a React element is, and how it differs from HTML.
React describes your UI with components and hooks, while ReactDOM turns that description into real browser DOM. Learn what each package exports.
Set up ESLint 9 flat config and Prettier in a React project, keep them from conflicting, and add scripts for your editor and CI.
Add the React Developer Tools extension to Chrome, check that it detects your app, and learn the Components and Profiler panels.
Tour a new Vite React project file by file, from index.html and main.jsx to App.jsx, public, vite.config.js and package.json.
Create React App is deprecated. See what Vite is, how it differs, and how to create a fast React project with it.
Install Node.js LTS and npm, check the setup, and learn the npm commands and package.json basics you need to start building React apps.
A practical checklist of the JavaScript features React code uses every day, with short examples of where each one appears in components.
The virtual DOM is React's lightweight copy of the UI. See how React compares trees and updates only the parts of the page that changed.