yarn create vite
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, { useEffect, useState } from 'react' | |
| import axios from 'axios' | |
| import Debugger from './Debugger' | |
| function App() { | |
| const [json, setJson] = useState(null) | |
| useEffect(() => { | |
| axios.get('url').then(response => { | |
| setJson(response.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
| module.exports = { | |
| transform: { | |
| '^.+\\.(t|j)sx?$': [ | |
| '@swc/jest', | |
| { | |
| jsc: { | |
| parser: { | |
| syntax: 'ecmascript', | |
| 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
| module.exports = { | |
| transform: { | |
| '\\.svg$': '<rootDir>/__mocks__/svg-transformer.js', | |
| }, | |
| } |
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 nookies from 'nookies' | |
| class ServerSideAuth { | |
| static #key = 'token' | |
| static #cookies = nookies | |
| static #isAuthenticated = token => { | |
| const response = fetch('http://localhost:3000/api/me', { | |
| headers: { |
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 {Router} from 'next/router' | |
| import NProgress from 'nprogress' | |
| NProgress.configure() | |
| Router.events.on('routeChangeStart', () => NProgress.start()) | |
| Router.events.on('routeChangeComplete', () => NProgress.done()) | |
| Router.events.on('routeChangeError', () => NProgress.done()) |
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
| new Array().forEach.call(document.querySelectorAll('*'), element => { | |
| if (element.offsetWidth > document.documentElement.offsetWidth) { | |
| console.log(element) | |
| } | |
| }) |
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 getPrefersColorScheme = () => { | |
| if ('matchMedia' in window) { | |
| const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches; | |
| return isDark ? 'dark' : 'light'; | |
| } | |
| return 'light'; | |
| }; | |
| export default getPrefersColorScheme; |
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 fn = (string: string /* yyyy-mm-dd */): Date => { | |
| const [year, month, day] = string.split('-').map(Number); | |
| const date = new Date(year, month - 1, day); | |
| return date; | |
| }; |
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 type { RootState } from '@app/store'; | |
| declare module 'react-redux' { | |
| export function useSelector<TState = RootState, TSelected = unknown>( | |
| selector: (state: TState) => TSelected, | |
| equalityFn?: (left: TSelected, right: TSelected) => boolean, | |
| ): TSelected; | |
| } |
NewerOlder