diff options
| author | Pinapelz <yukais@pinapelz.com> | 2024-08-23 15:06:37 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2024-08-23 15:06:37 -0700 |
| commit | e970aa7a26fecfa38041bb1cfa59a1d5f40a0194 (patch) | |
| tree | 5b226c90eb2215f1ab95ed72648069a60b40f745 /src/components/AnotherComponent.tsx | |
| parent | 471bd1f064766c33ee62b4789ca097da4d57978f (diff) | |
initial groundwork for interactivity via mdx
Diffstat (limited to 'src/components/AnotherComponent.tsx')
| -rw-r--r-- | src/components/AnotherComponent.tsx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/components/AnotherComponent.tsx b/src/components/AnotherComponent.tsx new file mode 100644 index 0000000..f74e924 --- /dev/null +++ b/src/components/AnotherComponent.tsx @@ -0,0 +1,28 @@ +import React, { useState, useEffect } from 'react'; + +const AnotherComponent: React.FC = () => { + const [selectedWorld, setSelectedWorld] = useState<string | null>(null); + + useEffect(() => { + // Load selected world from localStorage + const savedWorld = localStorage.getItem('selectedWorld'); + if (savedWorld) { + setSelectedWorld(savedWorld); + } + }, []); + + return ( + <div> + <p>Selected World: {selectedWorld}</p> + <button onClick={() => { + const newWorld = 'New World'; + setSelectedWorld(newWorld); + localStorage.setItem('selectedWorld', newWorld); // Save to localStorage + }}> + Change World + </button> + </div> + ); +}; + +export default AnotherComponent;
\ No newline at end of file |
