Skip to content

Commit a7e795a

Browse files
acharyakavitacarbonrobotKenanYusuf
authored
add ssr documentation file (#2774)
Co-authored-by: Charlie Brown <carbonrobot@gmail.com> Co-authored-by: Kenan Yusuf <kenan.m.yusuf@gmail.com>
1 parent 39416ec commit a7e795a

File tree

1 file changed

+37
-0
lines changed
  • docs/src/content/introduction

1 file changed

+37
-0
lines changed

docs/src/content/introduction/ssr.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
id: 1
3+
title: Server Side Rendering
4+
category: introduction
5+
type: docs
6+
scope: null
7+
---
8+
9+
# Server Side Rendering
10+
11+
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.
12+
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.
13+
14+
```jsx
15+
"use client";
16+
import React from 'react';
17+
import { VictoryBar, VictoryChart, VictoryTheme } from "victory";
18+
19+
const data = [
20+
{ quarter: 1, earnings: 13000 },
21+
{ quarter: 2, earnings: 16500 },
22+
{ quarter: 3, earnings: 14250 },
23+
{ quarter: 4, earnings: 19000 }
24+
];
25+
26+
const App = ()=>{
27+
return (
28+
<div style={styles.container}>
29+
<VictoryChart width={350} theme={VictoryTheme.material}>
30+
<VictoryBar data={data} x="quarter" y="earnings" />
31+
</VictoryChart>
32+
</div>
33+
);
34+
}
35+
36+
export default App;
37+
```

0 commit comments

Comments
 (0)