Skip to content

Commit 06a3d43

Browse files
committed
use new react transform, i guess
1 parent 904e9b2 commit 06a3d43

20 files changed

+66
-72
lines changed

build.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const ctx = await esbuild.context({
5151
target: resolveToEsbuildTarget(browserslist()),
5252
loader: { '.woff2': 'file' },
5353
metafile: !dev,
54+
jsxDev: dev,
5455
});
5556

5657
if (dev) {

src/About.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import type React from 'react';
22

33
const About: React.FC = () => (
44
<>

src/Data.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import React, { useCallback } from 'react';
22
import type { FeatureCollection, Point } from 'geojson';
33
import FileInput from './FileInput';
44
import MaybeError from './MaybeError';
@@ -12,7 +12,7 @@ const Data: React.FC = () => {
1212
const count = useAppSelector((state) => state.data.photos.features.length);
1313
const error = useAppSelector((state) => state.data.error);
1414

15-
const onFile = React.useCallback(
15+
const onFile = useCallback(
1616
(file: File) => {
1717
parseData(file).then(
1818
(data) =>

src/FileInput.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import React, { useCallback, useRef } from 'react';
22

33
type Kind = 'csv' | 'kml' | 'json';
44

@@ -21,11 +21,11 @@ const exts: Record<Kind, string> = {
2121
};
2222

2323
const FileInput: React.FC<Props> = ({ kind, onFile, children }) => {
24-
const inputRef = React.useRef<HTMLInputElement>(null);
24+
const inputRef = useRef<HTMLInputElement>(null);
2525

26-
const onLoadClick = React.useCallback(() => {
26+
const onLoadClick = useCallback(() => {
2727
inputRef.current?.click();
28-
}, [inputRef]);
28+
}, []);
2929

3030
const onFileChange: React.ChangeEventHandler<HTMLInputElement> =
3131
React.useCallback(

src/Game/BasicInput.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import * as React from 'react';
1+
import React, { useCallback } from 'react';
22
import { setBasic } from '../gameSlice';
33
import { useAppDispatch, useAppSelector } from '../store';
44

55
const BasicInput = () => {
66
const dispatch = useAppDispatch();
77
const text = useAppSelector((state) => state.game.basicText);
8-
const onChange: React.ChangeEventHandler<HTMLInputElement> =
9-
React.useCallback(
10-
(evt) => dispatch(setBasic(evt.target.value)),
11-
[dispatch]
12-
);
8+
const onChange: React.ChangeEventHandler<HTMLInputElement> = useCallback(
9+
(evt) => dispatch(setBasic(evt.target.value)),
10+
[dispatch]
11+
);
1312

1413
return (
1514
<label>

src/Game/LineInput.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import React, { useCallback } from 'react';
22
import FileInput from '../FileInput';
33
import {
44
setLine0,
@@ -18,22 +18,20 @@ const LineInput = () => {
1818
(state) => state.game.lineTarget.geometry.coordinates.length === 2
1919
);
2020
const wraparound = useAppSelector((state) => state.game.lineWraparound);
21-
const onChange0: React.ChangeEventHandler<HTMLInputElement> =
22-
React.useCallback(
23-
(evt) => dispatch(setLine0(evt.target.value)),
24-
[dispatch]
25-
);
26-
const onChange1: React.ChangeEventHandler<HTMLInputElement> =
27-
React.useCallback(
28-
(evt) => dispatch(setLine1(evt.target.value)),
29-
[dispatch]
30-
);
21+
const onChange0: React.ChangeEventHandler<HTMLInputElement> = useCallback(
22+
(evt) => dispatch(setLine0(evt.target.value)),
23+
[dispatch]
24+
);
25+
const onChange1: React.ChangeEventHandler<HTMLInputElement> = useCallback(
26+
(evt) => dispatch(setLine1(evt.target.value)),
27+
[dispatch]
28+
);
3129
const onChangeWraparound: React.ChangeEventHandler<HTMLInputElement> =
32-
React.useCallback(
30+
useCallback(
3331
(evt) => dispatch(setLineWraparound(evt.target.checked)),
3432
[dispatch]
3533
);
36-
const onFile = React.useCallback(
34+
const onFile = useCallback(
3735
async (file: File) => {
3836
try {
3937
const line = await parseLineString(file);

src/Game/MultiInput.tsx

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import React, { useCallback } from 'react';
22
import { setMulti } from '../gameSlice';
33
import { useAppDispatch, useAppSelector } from '../store';
44

@@ -7,28 +7,26 @@ const COORDS_RE = /[+-]?[0-9]+(?:\.?[0-9]+)?[,\s]+[+-]?[0-9]+(?:\.?[0-9]+)?/g;
77
const MultiInput = () => {
88
const dispatch = useAppDispatch();
99
const text = useAppSelector((state) => state.game.multiText);
10-
const onChange: React.ChangeEventHandler<HTMLTextAreaElement> =
11-
React.useCallback(
12-
(evt) => {
13-
dispatch(setMulti(evt.target.value));
14-
},
15-
[dispatch]
16-
);
17-
const onPaste: React.ClipboardEventHandler<HTMLTextAreaElement> =
18-
React.useCallback(
19-
(evt) => {
20-
const data = evt.clipboardData.getData('text/plain');
21-
let results: string[] = [];
22-
for (const result of data.matchAll(COORDS_RE)) {
23-
results.push(result[0]);
24-
}
25-
if (results.length > 0) {
26-
evt.preventDefault();
27-
dispatch(setMulti(results.join('\n')));
28-
}
29-
},
30-
[dispatch]
31-
);
10+
const onChange: React.ChangeEventHandler<HTMLTextAreaElement> = useCallback(
11+
(evt) => {
12+
dispatch(setMulti(evt.target.value));
13+
},
14+
[dispatch]
15+
);
16+
const onPaste: React.ClipboardEventHandler<HTMLTextAreaElement> = useCallback(
17+
(evt) => {
18+
const data = evt.clipboardData.getData('text/plain');
19+
let results: string[] = [];
20+
for (const result of data.matchAll(COORDS_RE)) {
21+
results.push(result[0]);
22+
}
23+
if (results.length > 0) {
24+
evt.preventDefault();
25+
dispatch(setMulti(results.join('\n')));
26+
}
27+
},
28+
[dispatch]
29+
);
3230
return (
3331
<label>
3432
Target coordinates (one per line):

src/Game/Params.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import type React from 'react';
22
import MaybeError from '../MaybeError';
33
import { GameMode } from '../game-modes';
44
import { useAppSelector } from '../store';

src/Game/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import type React from 'react';
22
import { Selector } from '../Radio';
33
import { GameMode, Geoid } from '../game-modes';
44
import { setGeoid, setMode } from '../gameSlice';

src/Icon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import type React from 'react';
22

33
interface Props {
44
name: string;

0 commit comments

Comments
 (0)