aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/AnotherComponent.tsx
blob: f74e92493555aa1b9ee2e68bdb6cac4469593bbd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage