现有如下代码:
function Button1() {
const [count, setCount] = React.useState(0);
const handleClick = React.useCallback(function () {
console.log(count);
setCount(count + 1);
}, []);
return (| schema: 'https://jihulab.com/api/graphql' | |
| documents: ['graphql/**/*.graphql'] | |
| ignoreNoDocuments: true | |
| generates: | |
| 'graphql/dist/types.ts': | |
| plugins: ['typescript'] | |
| 'graphql/dist/': | |
| preset: 'near-operation-file' | |
| presetConfig: | |
| folder: 'dist' |
| import { | |
| atom, | |
| atomFamily, | |
| AtomFamilyOptions, | |
| AtomOptions, | |
| ReadWriteSelectorFamilyOptions, | |
| ReadWriteSelectorOptions, | |
| selector, | |
| selectorFamily, | |
| SerializableParam |
| import { createContext, createElement, useContext, useState, useCallback } from 'react' | |
| /** @typedef {{ [language: string] : { [text: string]: string} }} Translations */ | |
| const I18nContext = createContext({ | |
| /** @type {string} */ | |
| language: '', | |
| /** @param {string} language */ | |
| setLanguage(language) {}, | |
| /** @type {Translations} */ |
| /** | |
| * @callback Tween | |
| * @param {number} x | |
| * @returns {number} | |
| */ | |
| /** | |
| * @callback Easing | |
| * @param {number} x | |
| * @returns {number} | |
| */ |
现有如下代码:
function Button1() {
const [count, setCount] = React.useState(0);
const handleClick = React.useCallback(function () {
console.log(count);
setCount(count + 1);
}, []);
return (| (function (_) { | |
| var $ = document.createElement('SCRIPT') | |
| $.src = _ | |
| $.onerror = function () { alert('Failed to load ' + _) } | |
| document.body.appendChild($) | |
| } ("data:application/javascript,alert('Hello, world.')")) |
| import React, { | |
| createContext, | |
| useState, | |
| useContext | |
| } from 'react' | |
| const AppContext = createContext({ | |
| checking: true, | |
| setChecking (checking) {} | |
| }) |
| import { createRef, useState, useEffect, useContext } from 'react' | |
| export function useReducer(reducer, initialArg, init) { | |
| const [stateRef] = useState(() => { | |
| if (init === undefined) { | |
| return createRef(initialArg) | |
| } else { | |
| return createRef(init(initialArg))) | |
| } | |
| }) |
| interface Cat { | |
| kind: "cat"; | |
| name: string; | |
| } | |
| interface Dog { | |
| kind: "dog"; | |
| name: string; | |
| } |