MDX Component Patterns
Quick Reference
Component Decision Tree
Need
Component
Helpful tip or terminology
(h4) Titled Pitfall
(h5) Titled Note
(h4) Recipe items
(h4) Challenge items
(h4)
Callout Spacing Rules
Callout components (Note, Pitfall, DeepDive) require a
blank line after the opening tag
before content begins.
Never place consecutively:
Don't do X {/pitfall-x/}
Explanation.
Don't do Y {/pitfall-y/}
Explanation.
Correct - separated:
(h4) heading with an ID.
There is no directive for Server Components. {/no-directive/}
A common misunderstanding is that Server Components are denoted by "use server", but there is no directive for Server Components. The "use server" directive is for Server Functions.
Version-Specific Note
<SomeContext> as a provider.
In older versions of React, use <SomeContext.Provider>.
(h5) heading with an ID.
Calling different memoized functions will read from different caches. {/pitfall-different-caches/}
To access the same cache, components must call the same memoized function.
Pitfall with Wrong/Right Code
useFormStatus will not return status information for a <form> rendered in the same component. {/pitfall-same-component/}
``js
function Form() {
// 🔴pending` will never be true
const { pending } = useFormStatus();
return