Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank1513 committed Feb 21, 2024
1 parent ea75cea commit 7a9dd33
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
19 changes: 19 additions & 0 deletions packages/shared-ui/src/root/counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use client";

import useRGS from "r18gs";

export default function Counter() {
const [count, setCount] = useRGS("count", 0);
return (
<div>
<h2>Clinet component 1</h2>
<input
onChange={e => {
setCount(parseInt(e.target.value.trim()));
}}
type="number"
value={count}
/>
</div>
);
}
13 changes: 13 additions & 0 deletions packages/shared-ui/src/root/display.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use client";

import useRGS from "r18gs";

export default function Display() {
const [count] = useRGS<number>("count");
return (
<div>
<h2>Client component 2</h2>
<b>{count}</b>
</div>
);
}
21 changes: 19 additions & 2 deletions packages/shared-ui/src/root/hero.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import styles from "../root-layout.module.css";
import { Logo } from "../common/logo";
import Counter from "./counter";
import Display from "./display";

export function Hero() {
return (
<div className={styles.center}>
<div>
<h1>
Build with <Logo />
Share global client state with <Logo />
</h1>
<p>Unleash the power of React Server Components!</p>
<p>
Unleash the power of React Server Components! No wrapper required.
<br /> Supports tree shakable libraries.
</p>
<br />
<br />
<br />
<p>Sharing state between client components without any wrapper or provider.</p>
<div className={styles.center}>
<Counter />
<Display />
</div>
<div className={styles.center}>
<Counter />
<Display />
</div>
</div>
</div>
);
Expand Down

0 comments on commit 7a9dd33

Please sign in to comment.