This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useState} from 'react'; | |
const PixabaySearch = () => { | |
const [query, setQuery] = useState('nature'); | |
const [imageType, setImageType] = useState('photo'); | |
const [results, setResults] = useState([]); | |
const [loading, setLoading] = useState(false); | |
const [error, setError] = useState(null); | |
const apiKey = '50059311-67b92461e0c6542f48deaee0e'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useState} from 'react'; | |
const PetForm = () => { | |
const [formData, setFormData] = useState({ | |
name: '', | |
status: 'available', | |
category: '', | |
tags: '', | |
photos: [], | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useState} from 'react'; | |
const App = () => { | |
const textUrl = 'https://gist.githubusercontent.com/sunmeat/5120f241ab0f407138b7c1dc479a2f02/raw/a01e873da40a27bada0192e4e75e632586623329/index.html'; | |
const imageUrl = 'https://raw.githubusercontent.com/sunmeat/gallery/main/MyApplication/cats/cat%20(1).jpg'; | |
const jsonObjectUrl = 'https://jsonplaceholder.typicode.com/users/1'; | |
const jsonArrayUrl = 'https://jsonplaceholder.typicode.com/posts'; | |
const postUrl = 'https://petstore.swagger.io/v2/pet'; | |
const [text, setText] = useState(''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useState} from 'react'; | |
const apiKey = '50059311-67b92461e0c6542f48deaee0e'; | |
function App() { | |
const [query, setQuery] = useState('nature'); | |
const [imageType, setImageType] = useState('photo'); | |
const [results, setResults] = useState([]); | |
const [loading, setLoading] = useState(false); | |
const [error, setError] = useState(''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.jsx: | |
import React, {createContext, useContext, useState} from 'react'; | |
import './App.css'; | |
// контекст аутентификации | |
const AuthContext = createContext(); | |
// провайдер контекста аутентификации | |
function AuthProvider({children}) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.jsx: | |
import React, {createContext, useContext, useState} from 'react'; | |
import './App.css'; | |
// контекст для темы | |
const ThemeContext = createContext(); | |
/* ThemeContext используется для хранения текущей темы (theme) и функции переключения (toggleTheme), | |
которые передаются всем компонентам через ThemeContext.Provider в компоненте App |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cartReducer.jsx | |
const initialCartState = { | |
items: [], | |
total: 0, | |
}; | |
function cartReducer(state, action) { | |
switch (action.type) { | |
case 'ADD_ITEM': | |
return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.jsx: | |
import { useReducer, useEffect, useState } from 'react'; | |
import './App.css'; | |
// начальное состояние | |
const initialState = { | |
loading: false, | |
data: null, | |
error: null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.jsx: | |
import {useEffect, useReducer, useRef, useState} from 'react'; | |
import './App.css'; | |
// начальное состояние | |
const initialState = { | |
step: 1, | |
components: { | |
core: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.jsx: | |
import {useReducer} from 'react'; | |
import './App.css'; | |
// начальное состояние | |
const initialState = { | |
count: 0, | |
}; |