React 18 and Vite (#4510)

This commit is contained in:
Matthew Penner 2022-11-25 13:25:03 -07:00 committed by GitHub
parent 1bb1b13f6d
commit 21613fa602
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
244 changed files with 4547 additions and 8933 deletions

View file

@ -1,6 +1,7 @@
import React, { useMemo } from 'react';
import styled from 'styled-components/macro';
import { v4 } from 'uuid';
import type { ChangeEvent, ReactNode } from 'react';
import { useMemo } from 'react';
import { nanoid } from 'nanoid';
import styled from 'styled-components';
import tw from 'twin.macro';
import Label from '@/components/elements/Label';
import Input from '@/components/elements/Input';
@ -42,12 +43,12 @@ export interface SwitchProps {
description?: string;
defaultChecked?: boolean;
readOnly?: boolean;
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
children?: React.ReactNode;
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
children?: ReactNode;
}
const Switch = ({ name, label, description, defaultChecked, readOnly, onChange, children }: SwitchProps) => {
const uuid = useMemo(() => v4(), []);
const uuid = useMemo(() => nanoid(), []);
return (
<div css={tw`flex items-center`}>
@ -57,7 +58,7 @@ const Switch = ({ name, label, description, defaultChecked, readOnly, onChange,
id={uuid}
name={name}
type={'checkbox'}
onChange={(e) => onChange && onChange(e)}
onChange={e => onChange && onChange(e)}
defaultChecked={defaultChecked}
disabled={readOnly}
/>