writing-react-effects

Writing React Effects Skill

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "writing-react-effects" with this command: npx skills add dust-tt/dust/dust-tt-dust-writing-react-effects

Writing React Effects Skill

Guides writing React components that avoid unnecessary useEffect calls.

Core Principle

Effects are an escape hatch for synchronizing with external systems (network, DOM, third-party widgets). If there's no external system, you don't need an Effect.

Calculate Derived State During Rendering

If a value can be computed from current props/state, do not store it in state or update it in an effect. Derive it during render to avoid extra renders and state drift. Do not set state in effects solely in response to prop changes; prefer derived values or keyed resets instead.

Incorrect (redundant state and effect):

function Form() { const [firstName, setFirstName] = useState('First') const [lastName, setLastName] = useState('Last') const [fullName, setFullName] = useState('')

useEffect(() => { setFullName(firstName + ' ' + lastName) }, [firstName, lastName])

return <p>{fullName}</p> }

Correct (derive during render):

function Form() { const [firstName, setFirstName] = useState('First') const [lastName, setLastName] = useState('Last') const fullName = firstName + ' ' + lastName

return <p>{fullName}</p> }

References: You Might Not Need an Effect

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

react-hook-form-writer

No summary provided by upstream source.

Repository SourceNeeds Review
General

dust-mcp-server

No summary provided by upstream source.

Repository SourceNeeds Review
General

dust-temporal

No summary provided by upstream source.

Repository SourceNeeds Review
General

dust-llm

No summary provided by upstream source.

Repository SourceNeeds Review