Q:

Get children of state object

In my react-app, I fetch data from the server and store it in the state in data like this:
  React.useEffect(() => {
    const fetchWidgets = async () => {
      const response = await fetch("http://localhost:1202/data");
      const responseData = await response.json();
      setData(responseData);
    };
    fetchWidgets();
  }, []);

The resulting object looks loke this: 
data = {
    "Widget1": "notes",
    "Widget2": "weather",
    "Widget3": "clock",
    "Widget4": "news"
  }

If I want to get the value of Widget1, how can I do that? 
If I try data. Widget1 I get this error message: Property 'Widget1' does not exist on type 'object'. 
Thanks for your help! 

A:

You need to type of value useState returns
interface DataType {
    [key: string]: string
}

const [data, setState] = useState<DataType>({})

