onCancel

Handle cancellation when user closes the picker

Cancel Callback

The onCancel event fires when user clicks Cancel or backdrop:

Cancellation Handler

Tracks how many times picker was cancelled

Cancelled: 0 times

import { Timepicker } from "timepicker-ui-react";
import { useState } from "react";
function App() {
const [cancelCount, setCancelCount] = useState(0);
return (
<div>
<Timepicker
onCancel={() => {
setCancelCount((prev) => prev + 1);
}}
/>
<p>Cancelled: {cancelCount} times</p>
</div>
);
}

Use Cases

  • Revert form changes
  • Track user behavior analytics
  • Reset temporary state
  • Show "selection cancelled" message