A react component to display a stopwatch.
npm install @kitsuyui/react-stopwatch
Simple stopwatch React component.
Storybook: https://react-playground.docs.kitsuyui.com/storybook/
``sh`
npm install @kitsuyui/react-stopwatch
`sh`
yarn add @kitsuyui/react-stopwatch
`sh`
pnpm add @kitsuyui/react-stopwatch
`tsx
import { StopWatchContainer, MinimalStopwatch } from '@kitsuyui/react-stopwatch'
const Stopwatch = () => {
return (
{(props: StopwatchProps) =>
)
}
`
StopwatchContainer is a component that provides StopwatchContext.
Stopwatchs are pure components that do not depend on StopwatchContext. Accept StopwatchProps as props.
So you can define your own Stopwatch component by same interface.
`typescript
export interface StopwatchValue {
elapsedTime: number
running: boolean
}
export interface StopwatchActions {
start(): void
stop(): void
toggle(): void
reset(): void
}
export type StopwatchProps = StopwatchValue & StopwatchActions
``
MIT