27 lines
612 B
React
27 lines
612 B
React
import React, { useState, useEffect } from 'react'
|
|
import { create } from 'zustand'
|
|
|
|
const useUserStore = create(set => ({
|
|
fetchUser: async userId => {
|
|
set({ isLoading: true, error: null})
|
|
try {
|
|
const response = await fetch(`api/users/${userId}`)
|
|
const user = await response.json()
|
|
set({user, isLoading: false})
|
|
} catch (error) {
|
|
set({error: error.message, isLoading: false})
|
|
}
|
|
}
|
|
}))
|
|
|
|
|
|
function App() {
|
|
return (
|
|
<>
|
|
<h1>Практика по созданию списка задач</h1>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default App
|