From cc79d1956b7691cede7a6f9f25f084bb9bb06aa2 Mon Sep 17 00:00:00 2001 From: Laktionov Anton Date: Thu, 11 Jun 2026 20:49:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=B0=D1=81=D0=B8=D0=BD=D1=85=D1=80=D0=BE=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.jsx | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 0126d06..13fe93a 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,32 +1,24 @@ import React, { useState, useEffect } from 'react' import { create } from 'zustand' -const useLightStore = create(set => ({ - isLightOn: false, - toggleLight: () => set(state => ({isLightOn: !state.isLightOn})), - turnOn: () => set({isLightOn:true}), - turnOff: () => set({isLightOn:false}), +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 LightButton() { - const toggleLight = useLightStore(state => state.toggleLight) - return () -} - -function LightOff() { - const lightOff = useLightStore(state => state.turnOff) - return () -} function App() { - const isLightOn = useLightStore(state => state.isLightOn) - return ( <>

Практика по созданию списка задач

-
Лампочка: {isLightOn ? 'Включена' : 'Выключена'}
- - ) }