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
| modules: | |
| --api | |
| --store | |
| -- actions.ts | |
| -- reducer.ts | |
| -- selectors.ts | |
| -- slice.ts | |
| -- sagas.ts |
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
| $color: #f2f5f9; | |
| $activeColor: #6666fe; | |
| $thumbColor: #6666fe; | |
| $trackHeight: 5px; | |
| $thumbHeight: 12px; | |
| $progressPercent: 50%; | |
| @mixin thumb { | |
| appearance: none; | |
| width: $thumbHeight; |
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
| 1.init: npm init -y | |
| 2. react: yarn add react react-dom | |
| 3. babel: yarn add --dev @babel/preset-react (jsx support) @babel/core @babel/preset-env | |
| 4. babel: yarn add --dev babel-loader (transpile modern syntax to browser supportable) | |
| 4.1 babel: yarn add --dev @babel/plugin-proposal-class-properties | |
| 5. babel: .babelrc with installed presets and plugins |
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
| function* rootSaga() { | |
| yield all([ | |
| takeLatest(login.type, loginUser), | |
| takeLatest(logout.type, logoutUser), | |
| takeLatest(loadNotes.type, fetchNotes), | |
| takeLatest(loadCategories.type, fetchCategories), | |
| takeLatest(loadSettings.type, fetchSettings), | |
| takeLatest(sync.type, syncData), | |
| takeLatest( | |
| [ |
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, { ComponentType, FC } from 'react'; | |
| import { Redirect, Route, RouteProps } from 'react-router-dom'; | |
| type Props = RouteProps & { | |
| component: ComponentType; | |
| redirect?: string; | |
| show?: boolean; | |
| }; | |
| const GuardedRoute: FC<Props> = ({ component: Component, redirect = '/', show = false, ...rest }) => { |
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, { ComponentType, FC } from 'react'; | |
| import { useSelector } from 'react-redux'; | |
| import { Redirect, Route, RouteProps } from 'react-router-dom'; | |
| import { getAuthenticated } from '@/store/selectors'; | |
| type PrivateRouteProps = RouteProps & { | |
| component: ComponentType; | |
| }; |
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
| module.exports = { | |
| parser: "@typescript-eslint/parser", | |
| parserOptions: { | |
| ecmaVersion: 2020, | |
| sourceType: "module", | |
| ecmaFeatures: { | |
| jsx: 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
| [...Array(26)].map((_, y) => String.fromCharCode(y + 65)).join('') |
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
| /* == Частичное применение (partial application) | |
| Напиши функцию partial(fn, a1, a2, ....), которая позволяет зафиксировать один или несколько аргументов функции. Пример: | |
| Есть функция с аргументами: | |
| f1(a, d, c, d) | |
| Мы можем с помощью partial сделать из нее функцию с меньшим числом аргументов, заранее задав значения для нескольких из них, например: | |
| var f2 = partial(f1, 1, 2); // фиксируем a = 1, b = 2 | |
| И вызов: f2(x, y) |
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
| function gcd(a = 10, b = 20) { | |
| if (b === 0) return a; | |
| return gcd(b, a % b); | |
| } |
NewerOlder