From a7e795a45d147d36f0bac0a931b27531b60fc211 Mon Sep 17 00:00:00 2001 From: Kavitha Acharya Date: Mon, 5 Feb 2024 10:13:19 -0500 Subject: [PATCH] add ssr documentation file (#2774) Co-authored-by: Charlie Brown Co-authored-by: Kenan Yusuf --- docs/src/content/introduction/ssr.md | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 docs/src/content/introduction/ssr.md diff --git a/docs/src/content/introduction/ssr.md b/docs/src/content/introduction/ssr.md new file mode 100644 index 000000000..9d848a03d --- /dev/null +++ b/docs/src/content/introduction/ssr.md @@ -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 ( +
+ + + +
+ ); +} + +export default App; +``` \ No newline at end of file