diff options
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 |
