Unverified Commit f0ff3c46 authored by Delba de Oliveira's avatar Delba de Oliveira Committed by GitHub

Docs: Update template.js section (#54370)

Fixes: https://vercel.slack.com/archives/C03S9JCH2Q5/p1692619927373449

- Updates wording on nesting, to say it's not the actual output, but rather how `template.js` nests between `layout.js` and its children.
- Remove mention of animations, needs further clarification. 
parent f6d2aa09
...@@ -206,13 +206,10 @@ Templates are similar to layouts in that they wrap each child layout or page. Un ...@@ -206,13 +206,10 @@ Templates are similar to layouts in that they wrap each child layout or page. Un
There may be cases where you need those specific behaviors, and templates would be a more suitable option than layouts. For example: There may be cases where you need those specific behaviors, and templates would be a more suitable option than layouts. For example:
- Enter/exit animations using CSS or animation libraries.
- Features that rely on `useEffect` (e.g logging page views) and `useState` (e.g a per-page feedback form). - Features that rely on `useEffect` (e.g logging page views) and `useState` (e.g a per-page feedback form).
- To change the default framework behavior. For example, Suspense Boundaries inside layouts only show the fallback the first time the Layout is loaded and not when switching pages. For templates, the fallback is shown on each navigation. - To change the default framework behavior. For example, Suspense Boundaries inside layouts only show the fallback the first time the Layout is loaded and not when switching pages. For templates, the fallback is shown on each navigation.
> **Recommendation:** We recommend using Layouts unless you have a specific reason to use Template. A template can be defined by exporting a default React component from a `template.js` file. The component should accept a `children` prop.
A template can be defined by exporting a default React component from a `template.js` file. The component should accept a `children` prop which will be nested segments.
<Image <Image
alt="template.js special file" alt="template.js special file"
...@@ -234,7 +231,7 @@ export default function Template({ children }) { ...@@ -234,7 +231,7 @@ export default function Template({ children }) {
} }
``` ```
The rendered output of a route segment with a layout and a template will be as such: In terms of nesting, `template.js` is rendered between a layout and its children. Here's a simplified output:
```jsx filename="Output" ```jsx filename="Output"
<Layout> <Layout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment