mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-25 11:59:11 +00:00
15 lines
313 B
TypeScript
15 lines
313 B
TypeScript
type ToggleProps = {
|
|
onChange?: (newState: boolean) => void;
|
|
children: React.ReactNode;
|
|
state: boolean;
|
|
};
|
|
|
|
export const Toggle = (props: ToggleProps) => (
|
|
<div
|
|
onClick={() => {
|
|
props.onChange?.(!props.state);
|
|
}}
|
|
>
|
|
{props.children}:<div>{props.state ? 'on' : 'off'}!</div>
|
|
</div>
|
|
);
|