Fix line endings
This commit is contained in:
parent
004dd7168e
commit
e712a054ae
|
@ -1,31 +1,31 @@
|
|||
import clsx from 'clsx'
|
||||
|
||||
export function Checkbox(props: {
|
||||
label: string
|
||||
checked: boolean
|
||||
toggle: (checked: boolean) => void
|
||||
className?: string
|
||||
}) {
|
||||
const { label, checked, toggle, className } = props
|
||||
|
||||
return (
|
||||
<div className={clsx(className, 'space-y-5')}>
|
||||
<div className="relative flex items-start">
|
||||
<div className="flex h-6 items-center">
|
||||
<input
|
||||
id={label}
|
||||
type="checkbox"
|
||||
className="h-5 w-5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
|
||||
checked={checked}
|
||||
onChange={(e) => toggle(!e.target.checked)}
|
||||
/>
|
||||
</div>
|
||||
<div className="ml-3">
|
||||
<label htmlFor={label} className="font-medium text-gray-700">
|
||||
{label}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
import clsx from 'clsx'
|
||||
|
||||
export function Checkbox(props: {
|
||||
label: string
|
||||
checked: boolean
|
||||
toggle: (checked: boolean) => void
|
||||
className?: string
|
||||
}) {
|
||||
const { label, checked, toggle, className } = props
|
||||
|
||||
return (
|
||||
<div className={clsx(className, 'space-y-5')}>
|
||||
<div className="relative flex items-start">
|
||||
<div className="flex h-6 items-center">
|
||||
<input
|
||||
id={label}
|
||||
type="checkbox"
|
||||
className="h-5 w-5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
|
||||
checked={checked}
|
||||
onChange={(e) => toggle(!e.target.checked)}
|
||||
/>
|
||||
</div>
|
||||
<div className="ml-3">
|
||||
<label htmlFor={label} className="font-medium text-gray-700">
|
||||
{label}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
// A hook soon to be added to the React core library:
|
||||
// https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
|
||||
// TODO: Once React adds this hook, use it instead.
|
||||
|
||||
import { useRef, useLayoutEffect, useCallback } from 'react'
|
||||
|
||||
type AnyFunction = (...args: any[]) => any
|
||||
|
||||
export function useEvent<T extends AnyFunction>(callback?: T) {
|
||||
const ref = useRef<AnyFunction | undefined>(() => {
|
||||
throw new Error('Cannot call an event handler while rendering.')
|
||||
})
|
||||
useLayoutEffect(() => {
|
||||
ref.current = callback
|
||||
})
|
||||
return useCallback<AnyFunction>(
|
||||
(...args) => ref.current?.apply(null, args),
|
||||
[]
|
||||
) as T
|
||||
}
|
||||
// A hook soon to be added to the React core library:
|
||||
// https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
|
||||
// TODO: Once React adds this hook, use it instead.
|
||||
|
||||
import { useRef, useLayoutEffect, useCallback } from 'react'
|
||||
|
||||
type AnyFunction = (...args: any[]) => any
|
||||
|
||||
export function useEvent<T extends AnyFunction>(callback?: T) {
|
||||
const ref = useRef<AnyFunction | undefined>(() => {
|
||||
throw new Error('Cannot call an event handler while rendering.')
|
||||
})
|
||||
useLayoutEffect(() => {
|
||||
ref.current = callback
|
||||
})
|
||||
return useCallback<AnyFunction>(
|
||||
(...args) => ref.current?.apply(null, args),
|
||||
[]
|
||||
) as T
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user