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 / different files.jsx
Created June 9, 2025 08:09
интернет магазин на классовых компонентах
App.jsx:
import React, {Component} from 'react';
import {QueryClient, QueryClientProvider, useQuery, useMutation, useQueryClient} from '@tanstack/react-query'; // npm install @tanstack/react-query
import Dexie from 'dexie'; // npm install dexie
import './App.css';
const db = new Dexie('CartDatabase');
db.version(1).stores({
cart: 'id, title, price, image, quantity',
@sunmeat
sunmeat / App.jsx
Created June 9, 2025 07:24
привязка обработчика события в классовом компоненте
import React, {useState, useEffect} from 'react';
import './App.css';
const getTimeWithMicroseconds = () => {
const now = new Date();
const micros = Math.floor(performance.now() * 1000) % 1000000;
return `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}.${micros.toString().padStart(6, '0')}`;
};
const FunctionalButton = ({width, height, color, text}) => {
@sunmeat
sunmeat / App.jsx
Last active June 9, 2025 07:20
сравнение жизненных циклов
import React, {useState, useEffect} from 'react';
import './App.css';
// время с микросекундами
const getTimeWithMicroseconds = () => {
const now = new Date();
const micros = Math.floor(performance.now() * 1000) % 1000000;
return `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}.${micros.toString().padStart(6, '0')}`;
};
@sunmeat
sunmeat / different files.jsx
Created June 9, 2025 05:54
сравнение функционального и классового компонента
App.jsx:
import React, {useState} from 'react';
import './App.css';
const FunctionalButton = ({width, height, color, text}) => {
const [clickCount, setClickCount] = useState(0);
const handleClick = () => {
setClickCount(clickCount + 1);
@sunmeat
sunmeat / different files.jsx
Created June 6, 2025 16:43
RTL + vitest example
App.jsx:
import {useState, useEffect, useCallback, useMemo} from 'react';
import {QueryClient, QueryClientProvider, useQuery, useMutation, useQueryClient} from '@tanstack/react-query';
import Dexie from 'dexie'; // npm install dexie
import './App.css';
const db = new Dexie('CartDatabase');
db.version(1).stores({
cart: 'id, title, price, image, quantity',
@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": "*"}})