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
Last active May 15, 2025 11:26
вызов функции обратного вызова для родителя (callbacks)
Content.jsx (родительская компонента):
import './Content.css';
import {useContext, useState} from 'react';
import {AppContext} from '../../contexts/AppContext.jsx';
import {MyButton} from '../mybutton/MyButton.jsx';
export function Content() {
const {theme, user} = useContext(AppContext);
// состояние для хранения количества кликов
@sunmeat
sunmeat / App.jsx
Created May 15, 2025 09:40
методы ЖЦ классового компонента
import React from 'react';
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 0
};
console.log('constructor');
}
@sunmeat
sunmeat / task.txt
Created May 14, 2025 18:09
задания на ООП джаваскрипт
написать 2-3 класса, которые будут полезны для вашего будущего финального проекта по джаваскрипту (защита 06.06.2025).
постараться применить как можно больше особенностей синтаксиса джаваскрипт (паттерн mixin, деструктурирование и тд).
ЛИБО:
выполнить одно любое задание из 11, доступных по ссылкам:
https://materials.itstep.org/content/0fd326fe-d42a-4675-9567-5406be94a43b/ru
https://materials.itstep.org/content/a7d24cff-b237-4b2b-962f-68fc4f6bb8fb/ru
@sunmeat
sunmeat / task.txt
Last active May 12, 2025 18:09
ДЗ на создание класса в джаваскрипт
1. Почитать про систему прототипирования в JS:
https://learn.javascript.ru/function-prototype
https://learn.javascript.ru/native-prototypes
2. Выполнить первое или второе задание на выбор по ссылке: https://materials.itstep.org/content/4cff49e1-88fb-44a6-9b5d-f4ee836ef81c/ru
Использовать ключевое слово class, сделать три свойства и метод. В методе применить document.write() для генерации контента на странице.
Создать один или несколько объектов на основе класса, запустить метод, проверить что всё работает.
Ссылку на гист/репозиторий с решением прислать в комментарий к этому ДЗ.
@sunmeat
sunmeat / different files
Last active May 12, 2025 11:27
named export
// utils.jsx:
export function add(a, b) { return a + b; }
export function subtract(a, b) { return a - b; }
export const PI = 3.14;
// another file
import { add } from './utils'; // импортируем только add
import { add, subtract, PI } from './utils'; // импортируем всё
// именованные экспорты — лучший выбор по умолчанию.
@sunmeat
sunmeat / App.jsx
Created May 10, 2025 13:59
props simple example
import React from 'react'
import './App.css'
function MyButton(props) {
return (
<button style={{ backgroundColor: props.color }}>
Нажми меня
</button>
);
}
@sunmeat
sunmeat / App.jsx
Created May 10, 2025 13:55
state simple example
import React, {useState} from 'react'
import './App.css'
const getRandomColor = () => {
const letters = '0123456789ABCDEF';
let color = '#';
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
@sunmeat
sunmeat / App.jsx
Created May 10, 2025 13:45
component composition example
import React from 'react'
import './App.css'
function MyButton() {
return <button>Hello</button>
}
function BorderedButton() {
return (
<div className="bordered">
@sunmeat
sunmeat / App.jsx
Created May 10, 2025 13:37
first class component
import React, {useState} from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
function MyButton() {
return <button>Hello</button>
}
@sunmeat
sunmeat / App.jsx
Created May 10, 2025 13:29
very first functional component
import {useState} from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
function MyButton() {
return <button>Hello</button>
}
function App() {