new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

React · API reference · all subjects

dom rendering & hydration

3 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Document metadata tags can be rendered anywhere in component tree

React provides built-in support for rendering <title>, <meta>, and metadata <link> tags anywhere in your component tree. These work the same way in all environments, including fully client-side code, SSR, and RSC, providing built-in support for features pioneered by libraries like React Helmet.

flushSync forces synchronous DOM updates

Import flushSync from 'react-dom'. Wrap a state update in flushSync(() => { setState(...); }) to force React to update the DOM synchronously immediately after the wrapped code executes. This is useful when you need to read a ref immediately after a state update that affects the DOM.

Example: flushSync for immediate ref access

import { useState, useRef } from 'react'; import { flushSync } from 'react-dom'; function handleAdd() { const newTodo = { id: nextId++, text: text }; flushSync(() => { setText(''); setTodos([ ...todos, newTodo]); }); listRef.current.lastChild.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); } This ensures the DOM is updated before scrolling, so scrolling accesses the newly added element.

Give your agent this brain