Skip to content

Instantly share code, notes, and snippets.

View sunmeat's full-sized avatar
🐈
MEOW

Oleksandr Zahoruiko sunmeat

🐈
MEOW
View GitHub Profile
@sunmeat
sunmeat / App.jsx
Created June 4, 2025 11:15
базовый App.jsx
import {useState} from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
function App() {
const [count, setCount] = useState(0)
return (
<>
@sunmeat
sunmeat / App.test.jsx
Created June 4, 2025 11:13
пользовательские тесты для базовой версии App.jsx
import { render, screen, fireEvent } from '@testing-library/react' // импорт функций для рендеринга компонентов и взаимодействия с DOM
import App from './App' // импорт компоненты App, которую будем тестировать
describe('App component', () => { // группа тестов для компонента App
it('renders Vite and React logos', () => { // тест: проверяет, что логотипы Vite и React отображаются
render(<App />) // рендерим компонент App в виртуальный DOM
expect(screen.getByAltText('Vite logo')).toBeInTheDocument() // ожидаем, что изображение с alt "Vite logo" присутствует в документе
expect(screen.getByAltText('React logo')).toBeInTheDocument() // ожидаем, что изображение с alt "React logo" присутствует в документе
})
@sunmeat
sunmeat / eslint.config.js
Created June 4, 2025 11:08
предварительные настройки
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import vitest from 'eslint-plugin-vitest'
import vitestGlobals from 'globals'
export default [
{ ignores: ['dist'] },
{
@sunmeat
sunmeat / vite.config.js
Last active June 4, 2025 11:00
предварительные настройки
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
test: {
environment: 'jsdom',
globals: true,
setupFiles: './src/setupTests.js',
},
@sunmeat
sunmeat / требования.md
Last active June 3, 2025 10:18
техническое задание для экзаменационного проекта по React

🛒 Интернет-магазин на React (аналог Rozetka)

📖 Описание проекта

Проект должен представлять собой полноценный интернет-магазин, аналогичный Rozetka, разработанный с использованием React (функциональные компоненты) и современных инструментов фронтенд-разработки. Должны быть реализованы:

  • Главная страница
  • Страницы категорий и товаров
  • Корзина
  • Оформление заказа
@sunmeat
sunmeat / different files
Created June 3, 2025 09:35
render.com example REACT
App.jsx (client side):
import { useState, useRef } from 'react';
const SERVER_URL = 'https://netserver-dkf4.onrender.com/send';
function App() {
const [inputValue, setInputValue] = useState('5');
const [isSending, setIsSending] = useState(false);
const [messages, setMessages] = useState([]);
@sunmeat
sunmeat / different files
Created June 3, 2025 09:31
pythonanywhere server example + fetch API + решение проблемы CORS + REACT
https://www.pythonanywhere.com/user/sunmeat/files/home/sunmeat/alex.py?edit:
from flask import Flask, jsonify
from flask_cors import CORS
app = Flask(__name__)
# Enable CORS for all routes, allowing all origins
CORS(app, resources={r"/api/*": {"origins": "*"}})
@sunmeat
sunmeat / App.jsx
Last active June 3, 2025 09:26
IntersectionObserver
import { useState, useEffect, useRef } from 'react';
import { QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-query';
import './App.css';
const API_URL = 'http://sunmeat.atwebpages.com/react/api.php';
const queryClient = new QueryClient();
const truncateText = (text, maxLength) =>
text.length > maxLength ? text.slice(0, maxLength) + '...' : text;
@sunmeat
sunmeat / different files
Created June 3, 2025 09:03
react + php + files
создать папку files в папке react
=======================================================================================
App.jsx:
import { useState, useEffect } from 'react';
import { QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-query';
import './App.css';
@sunmeat
sunmeat / App.jsx
Created June 3, 2025 06:25
tanstack query example react + dexie.js
import {useState, useEffect} from 'react';
import {QueryClient, QueryClientProvider, useQuery} from '@tanstack/react-query';
import Dexie from 'dexie';
import './App.css';
// инициализация Dexie, npm install dexie
// https://dexie.org/
const db = new Dexie('CartDatabase');
db.version(1).stores({
cart: '++id, title, price, image', // схема для таблицы корзины