Skip to content

Commit

Permalink
add some <Root> doc
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Dec 17, 2020
1 parent dc92eda commit 2f0914b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion website/docs/using-themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,30 @@ And if you want to use Bootstrap styling, you can swap out the theme with `theme
}
```

The content plugin remains the same and the only thing you need to change is the theme.
## Wrapper your site with `<Root>`

A `<Root>` theme component is rendered at the very top of your Docusaurus site.

It allows you to wrap your site with additional logic, by creating a file at `website/src/theme/Root.js`:

```js title="website/src/theme/Root.js"
import React from 'react';

// Default implementation, that you can customize
function Root({children}) {
return <>{children}</>;
}

export default Root;
```

This component is applied above the router and the theme `<Layout>`, and will **never unmount**.

:::tip

Use this component render React Context providers and global stateful logic.

:::

## Swizzling theme components

Expand Down

0 comments on commit 2f0914b

Please sign in to comment.