Skip to content

Commit 7073395

Browse files
committed
style: drop React default import
1 parent 92772cb commit 7073395

File tree

16 files changed

+87
-88
lines changed

16 files changed

+87
-88
lines changed

docs/components/JsonViewerPreview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { JsonViewerProps } from '@textea/json-viewer'
22
import { JsonViewer } from '@textea/json-viewer'
3-
import React from 'react'
3+
import type { FC } from 'react'
44

5-
export const JsonViewerPreview: React.FC<JsonViewerProps> = (props) => {
5+
export const JsonViewerPreview: FC<JsonViewerProps> = (props) => {
66
return (
77
<JsonViewer
88
theme='auto'

docs/pages/_app.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'nextra-theme-docs/style.css'
22

33
import type { AppProps } from 'next/app'
4-
import React from 'react'
54

65
export default function Nextra ({ Component, pageProps }: AppProps) {
76
return <Component {...pageProps} />

docs/pages/full/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import {
2222
JsonViewer
2323
} from '@textea/json-viewer'
2424
import Image from 'next/image'
25-
import React, { useCallback, useEffect, useState } from 'react'
25+
import type { FC } from 'react'
26+
import { useCallback, useEffect, useState } from 'react'
2627

2728
import { ocean } from '../../lib/shared'
2829

@@ -109,7 +110,7 @@ const KeyRenderer: JsonViewerKeyRenderer = ({ path }) => {
109110
}
110111
KeyRenderer.when = (props) => props.value === 114.514
111112

112-
const IndexPage: React.FC = () => {
113+
const IndexPage: FC = () => {
113114
const [indent, setIndent] = useState(3)
114115
const [groupArraysAfterLength, setGroupArraysAfterLength] = useState(100)
115116
const [themeKey, setThemeKey] = useState<string>('light')

src/browser.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react'
21
import type { Root } from 'react-dom/client'
32
import { createRoot } from 'react-dom/client'
43

src/components/DataKeyPair.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Box } from '@mui/material'
2-
import type { ComponentProps } from 'react'
3-
import React, { useCallback, useMemo, useState } from 'react'
2+
import type { ComponentProps, FC, MouseEvent } from 'react'
3+
import { useCallback, useMemo, useState } from 'react'
44

55
import { useTextColor } from '../hooks/useColor'
66
import { useClipboard } from '../hooks/useCopyToClipboard'
@@ -28,7 +28,7 @@ export type DataKeyPairProps = {
2828

2929
type IconBoxProps = ComponentProps<typeof Box>
3030

31-
const IconBox: React.FC<IconBoxProps> = (props) => (
31+
const IconBox: FC<IconBoxProps> = (props) => (
3232
<Box
3333
component='span'
3434
{...props}
@@ -40,7 +40,7 @@ const IconBox: React.FC<IconBoxProps> = (props) => (
4040
/>
4141
)
4242

43-
export const DataKeyPair: React.FC<DataKeyPairProps> = (props) => {
43+
export const DataKeyPair: FC<DataKeyPairProps> = (props) => {
4444
const { value, path, nestedIndex } = props
4545
const propsEditable = props.editable ?? undefined
4646
const storeEditable = useJsonViewerStore(store => store.editable)
@@ -214,7 +214,7 @@ export const DataKeyPair: React.FC<DataKeyPairProps> = (props) => {
214214
opacity: 0.8
215215
}}
216216
onClick={
217-
useCallback((event: React.MouseEvent<HTMLSpanElement>) => {
217+
useCallback((event: MouseEvent<HTMLSpanElement>) => {
218218
if (event.isDefaultPrevented()) {
219219
return
220220
}

src/components/DataTypeLabel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import type { FC } from 'react'
22

33
import { DataBox } from './mui/DataBox'
44

@@ -7,7 +7,7 @@ export type DataLabelProps = {
77
enable?: boolean
88
}
99

10-
export const DataTypeLabel: React.FC<DataLabelProps> = ({
10+
export const DataTypeLabel: FC<DataLabelProps> = ({
1111
dataType
1212
, enable = true
1313
}) => {

src/components/DataTypes/Function.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Because in Next.js SSR, the function will be translated to other type
44
*/
55
import { Box, NoSsr } from '@mui/material'
6-
import React from 'react'
6+
import type { FC } from 'react'
77

88
import { useJsonViewerStore } from '../../stores/JsonViewerStore'
99
import type { DataItemProps } from '../../type'
@@ -41,7 +41,7 @@ const functionName = (func: Function) => {
4141
const lb = '{'
4242
const rb = '}'
4343

44-
export const PreFunctionType: React.FC<DataItemProps<Function>> = (props) => {
44+
export const PreFunctionType: FC<DataItemProps<Function>> = (props) => {
4545
return (
4646
<NoSsr>
4747
<DataTypeLabel dataType='function'/>
@@ -58,7 +58,7 @@ export const PreFunctionType: React.FC<DataItemProps<Function>> = (props) => {
5858
)
5959
}
6060

61-
export const PostFunctionType: React.FC<DataItemProps<Function>> = () => {
61+
export const PostFunctionType: FC<DataItemProps<Function>> = () => {
6262
return (
6363
<NoSsr>
6464
<Box component='span' className='data-function-end'>
@@ -68,7 +68,7 @@ export const PostFunctionType: React.FC<DataItemProps<Function>> = () => {
6868
)
6969
}
7070

71-
export const FunctionType: React.FC<DataItemProps<Function>> = (props) => {
71+
export const FunctionType: FC<DataItemProps<Function>> = (props) => {
7272
const functionColor = useJsonViewerStore(store => store.colorspace.base05)
7373
return (
7474
<NoSsr>

src/components/DataTypes/Object.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Box } from '@mui/material'
2-
import React, { useMemo, useState } from 'react'
2+
import type { FC } from 'react'
3+
import { useMemo, useState } from 'react'
34

45
import { useTextColor } from '../../hooks/useColor'
56
import { useIsCycleReference } from '../../hooks/useIsCycleReference'
@@ -28,7 +29,7 @@ function inspectMetadata (value: object) {
2829
return `${length} Items${name ? ` (${name})` : ''}`
2930
}
3031

31-
export const PreObjectType: React.FC<DataItemProps<object>> = (props) => {
32+
export const PreObjectType: FC<DataItemProps<object>> = (props) => {
3233
const metadataColor = useJsonViewerStore(store => store.colorspace.base04)
3334
const textColor = useTextColor()
3435
const isArray = useMemo(() => Array.isArray(props.value), [props.value])
@@ -75,7 +76,7 @@ export const PreObjectType: React.FC<DataItemProps<object>> = (props) => {
7576
)
7677
}
7778

78-
export const PostObjectType: React.FC<DataItemProps<object>> = (props) => {
79+
export const PostObjectType: FC<DataItemProps<object>> = (props) => {
7980
const metadataColor = useJsonViewerStore(store => store.colorspace.base04)
8081
const isArray = useMemo(() => Array.isArray(props.value), [props.value])
8182
const displayObjectSize = useJsonViewerStore(store => store.displayObjectSize)
@@ -109,7 +110,7 @@ function getIterator (value: any): value is Iterable<unknown> {
109110
return typeof value?.[Symbol.iterator] === 'function'
110111
}
111112

112-
export const ObjectType: React.FC<DataItemProps<object>> = (props) => {
113+
export const ObjectType: FC<DataItemProps<object>> = (props) => {
113114
const keyColor = useTextColor()
114115
const borderColor = useJsonViewerStore(store => store.colorspace.base02)
115116
const groupArraysAfterLength = useJsonViewerStore(store => store.groupArraysAfterLength)

src/components/DataTypes/createEasyType.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { InputBase } from '@mui/material'
2-
import React, { useCallback } from 'react'
2+
import type { ChangeEventHandler, ComponentType, FC } from 'react'
3+
import { memo, useCallback } from 'react'
34

45
import { useJsonViewerStore } from '../../stores/JsonViewerStore'
56
import type { Colorspace } from '../../theme/base16'
@@ -9,7 +10,7 @@ import { DataBox } from '../mui/DataBox'
910

1011
export function createEasyType<Value> (
1112
type: string,
12-
renderValue: React.ComponentType<Pick<DataItemProps<Value>, 'value'>>,
13+
renderValue: ComponentType<Pick<DataItemProps<Value>, 'value'>>,
1314
config: {
1415
colorKey: keyof Colorspace
1516
fromString?: (value: string) => Value
@@ -18,8 +19,8 @@ export function createEasyType<Value> (
1819
): Omit<DataType<Value>, 'is'> {
1920
const { fromString, colorKey, displayTypeLabel = true } = config
2021

21-
const Render = React.memo(renderValue)
22-
const EasyType: React.FC<DataItemProps<Value>> = (props) => {
22+
const Render = memo(renderValue)
23+
const EasyType: FC<DataItemProps<Value>> = (props) => {
2324
const storeDisplayDataTypes = useJsonViewerStore(store => store.displayDataTypes)
2425
const color = useJsonViewerStore(store => store.colorspace[colorKey])
2526
const onSelect = useJsonViewerStore(store => store.onSelect)
@@ -41,13 +42,13 @@ export function createEasyType<Value> (
4142
}
4243
}
4344

44-
const EasyTypeEditor: React.FC<EditorProps<Value>> = ({ value, setValue }) => {
45+
const EasyTypeEditor: FC<EditorProps<Value>> = ({ value, setValue }) => {
4546
const color = useJsonViewerStore(store => store.colorspace[colorKey])
4647
return (
4748
<InputBase
4849
value={value}
4950
onChange={
50-
useCallback<React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>>(
51+
useCallback<ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>>(
5152
(event) => {
5253
const value = fromString(event.target.value)
5354
setValue(value)

src/components/Icons.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { SvgIconProps } from '@mui/material'
22
import { SvgIcon } from '@mui/material'
3-
import React from 'react'
3+
import type { FC } from 'react'
44

5-
const BaseIcon: React.FC<SvgIconProps> = ({ d, ...props }) => {
5+
const BaseIcon: FC<SvgIconProps> = ({ d, ...props }) => {
66
return (
77
<SvgIcon {...props}>
88
<path d={d}/>
@@ -18,30 +18,30 @@ const ContentCopy = 'M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v
1818
const Edit = 'M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'
1919
const ExpandMore = 'M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z'
2020

21-
export const CheckIcon: React.FC<SvgIconProps> = (props) => {
21+
export const CheckIcon: FC<SvgIconProps> = (props) => {
2222
return <BaseIcon d={Check} {...props} />
2323
}
2424

25-
export const ChevronRightIcon: React.FC<SvgIconProps> = (props) => {
25+
export const ChevronRightIcon: FC<SvgIconProps> = (props) => {
2626
return <BaseIcon d={ChevronRight} {...props} />
2727
}
2828

29-
export const CircularArrowsIcon: React.FC<SvgIconProps> = (props) => {
29+
export const CircularArrowsIcon: FC<SvgIconProps> = (props) => {
3030
return <BaseIcon d={CircularArrows} {...props} />
3131
}
3232

33-
export const CloseIcon: React.FC<SvgIconProps> = (props) => {
33+
export const CloseIcon: FC<SvgIconProps> = (props) => {
3434
return <BaseIcon d={Close} {...props} />
3535
}
3636

37-
export const ContentCopyIcon: React.FC<SvgIconProps> = (props) => {
37+
export const ContentCopyIcon: FC<SvgIconProps> = (props) => {
3838
return <BaseIcon d={ContentCopy} {...props} />
3939
}
4040

41-
export const EditIcon: React.FC<SvgIconProps> = (props) => {
41+
export const EditIcon: FC<SvgIconProps> = (props) => {
4242
return <BaseIcon d={Edit} {...props} />
4343
}
4444

45-
export const ExpandMoreIcon: React.FC<SvgIconProps> = (props) => {
45+
export const ExpandMoreIcon: FC<SvgIconProps> = (props) => {
4646
return <BaseIcon d={ExpandMore} {...props} />
4747
}

0 commit comments

Comments
 (0)