Skip to content

Instantly share code, notes, and snippets.

Problem

I simplified the reproduction

import useSWR from "swr";
import React, { useState, useEffect } from "react";

const sleep = (ms) =>
  new Promise((resolve) => {
    setTimeout(() => resolve("foo"), ms);
@promer94
promer94 / index.md
Last active June 15, 2022 17:29
TypeScript-类型编程

TS 类型编程



it('should update data when polling interval has changed', async () => {
let a = 0
function App() {
const [int, setInt] = React.useState(200)
const { data } = useSWR('/api', () => a++, {
refreshInterval: int,
dedupingInterval: 100
})
return <div onClick={() => setInt(int + 100)}>count: {data}</div>
}
import {
useEffect,
useLayoutEffect,
useRef,
useContext,
useCallback,
useReducer
} from 'react'
import deepEqual from 'fast-deep-equal'
server {
listen 80 default_server;
listen [::]:80 default_server;
proxy_redirect off;
proxy_pass "http://127.0.0.1:3000";
}
{
"editor.formatOnSave": false,
"editor.detectIndentation": false,
"workbench.iconTheme": "material-icon-theme",
"gitlens.advanced.messages": {
"suppressCommitHasNoPreviousCommitWarning": false,
"suppressCommitNotFoundWarning": false,
"suppressFileNotUnderSourceControlWarning": false,
"suppressGitVersionWarning": false,
"suppressLineUncommittedWarning": false,
{
"parser": "babel-eslint",
"extends": ["react-app","airbnb","prettier/react","prettier"],
"rules": {
"jsx-a11y/href-no-hash": [0],
"generator-star-spacing": [0],
"consistent-return": [0],
"react/react-in-jsx-scope": [0],
"react/forbid-prop-types": [0],
"react/jsx-filename-extension": [1, { "extensions": [".js"] }],
@promer94
promer94 / package.json
Created March 19, 2018 07:13
my npm setting
{
"name": "editor_setting",
"version": "1.0.0",
"description": "vscode setting",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",