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
# Add these three lines to CORSify your server for everyone. | |
Header set Access-Control-Allow-Origin "*" | |
Header set Access-Control-Allow-Methods "GET,PUT,POST,DELETE" | |
Header set Access-Control-Allow-Headers "Content-Type, Authorization" |
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
// using custom hook in functional component | |
const Component: React.FC = () => { | |
const { requestStatus, sendRequest, removeStatusData } = useRequest(); | |
useEffect(() => { | |
if(props) sendRequest(getRecipientNameRequest(params)); // using sendRequest custom hook | |
}, [props]); // eslint-disable-line | |
useEffect(() => { | |
removeStatusData(); // remove status data if we need to clear data |
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
export const instance = axios.create({ baseURL: "https://geolocation-db.com/json/f9902210-97f0-11eb-a459-b997d30983f1" }); | |
export const getBannersRequest = () => instance.get(`background-image`); |
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
const [data, setData] = useState<IDepositCalcData[]>([]); | |
const [error, setError] = useState(" "); | |
const [alert, setAlert] = useState(""); | |
const [isLoading, setIsLoading] = useState(false); | |
try { | |
const result = await depositCalcRequest(unFormatSum(amount), currentDeposit.id, currentDeposit.capitalization); | |
if(result.data){ | |
setData(result.data.data); |
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
interface FsDocument extends HTMLElement { | |
msRequestFullscreen?: () => void; | |
webkitRequestFullScreen?: () => void; | |
mozRequestFullScreen?: () => void; | |
} | |
export function BtnFullScreen() { | |
const FullscreenIconClickHandler = () => { | |
const target = document.querySelector<FsDocument>('.game'); | |
if (target && target.requestFullscreen) target.requestFullscreen(); |
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
// for class coomponents | |
if (this.audio) { | |
this.audio.pause(); | |
} | |
this.audio = new Audio('audio_url'); | |
this.audio.play(); | |
// for functional components | |
const audioUrl = xIsNext ? 'https://timra.ru/portfolio/audio/cross.mp3' : 'https://timra.ru/portfolio/audio/zero.mp3'; |
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
npm i -D redux react-redux @types/react-redux redux-localstorage-simple | |
// --- --- --- --- --- --- --- --- STORE.js BEGIN --- --- --- --- --- --- --- --- | |
import {createStore, compose, applyMiddleware} from 'redux'; | |
import rootReducer from './reducers'; | |
import {save} from 'redux-localstorage-simple'; | |
// /* eslint-disable no-underscore-dangle */ | |
const composeEnhancers = | |
process.env.NODE_ENV !== 'production' && typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ |
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
interface HttpResponse<T> extends Response { | |
parsedBody?: T; | |
status: number; | |
redirect?: boolean; | |
} | |
interface IPost { | |
title?: string; | |
body?: string; | |
} |
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, { Component } from 'react'; | |
import { connect } from 'react-redux'; | |
import './TopicsScreen.css'; | |
class TopicsScreen extends Component { | |
render() { | |
return ( | |
<h2>Where are my topics?</h2> | |
); | |
} |
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
Show hidden characters
// Файл "tsconfig.json": | |
// - устанавливает корневой каталог проекта TypeScript; | |
// - выполняет настройку параметров компиляции; | |
// - устанавливает файлы проекта. | |
// Присутствие файла "tsconfig.json" в папке указывает TypeScript, что это корневая папка проекта. | |
// Внутри "tsconfig.json" указываются настройки компилятора TypeScript и корневые файлы проекта. | |
// Программа компилятора "tsc" ищет файл "tsconfig.json" сначала в папке, где она расположена, затем поднимается выше и ищет в родительских папках согласно их вложенности друг в друга. | |
// Команда "tsc --project C:\path\to\my\project\folder" берет файл "tsconfig.json" из папки, расположенной по данному пути. | |
// Файл "tsconfig.json" может быть полностью пустым, тогда компилятор скомпилирует все файлы с настройками заданными по умолчанию. | |
// Опции компилятора, перечисленные в командной строке перезаписывают собой опции, заданные в файле "tsconfig.json". |
NewerOlder