Skip to content

Commit

Permalink
add ssr documentation file (#2774)
Browse files Browse the repository at this point in the history
Co-authored-by: Charlie Brown <[email protected]>
Co-authored-by: Kenan Yusuf <[email protected]>
  • Loading branch information
3 people authored Feb 5, 2024
1 parent 39416ec commit a7e795a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/src/content/introduction/ssr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
id: 1
title: Server Side Rendering
category: introduction
type: docs
scope: null
---

# Server Side Rendering

In frameworks such as Next.js 13+, context is fully supported within Client Components, but it cannot be created or consumed directly within Server Components. This is because Server Components have no React state (since they're not interactive), and context is primarily used for rerendering interactive components deep in the tree after some React state has been updated.
Victory uses `createContext` to perform its operations and it must be rendered client side by adding the `use client` directive in your components when used in a framework with Server Side Component support.

```jsx
"use client";
import React from 'react';
import { VictoryBar, VictoryChart, VictoryTheme } from "victory";

const data = [
{ quarter: 1, earnings: 13000 },
{ quarter: 2, earnings: 16500 },
{ quarter: 3, earnings: 14250 },
{ quarter: 4, earnings: 19000 }
];

const App = ()=>{
return (
<div style={styles.container}>
<VictoryChart width={350} theme={VictoryTheme.material}>
<VictoryBar data={data} x="quarter" y="earnings" />
</VictoryChart>
</div>
);
}

export default App;
```

0 comments on commit a7e795a

Please sign in to comment.