Starting the timer:
import React from 'react';
import { useTimer } from 'library-react-hooks';
const Example: React.FC = () => {
const { setTimer} = useTimer();
return (
<div>
<button onClick={() => setTimer(10, { name: 'myTimer', autoFinish: true, callback: () => { console.log('finish') } })}>Button</button>
</div>
);
};
Attention! The component will be rerendered every second:
import React from 'react';
import { useListenTime } from 'library-react-hooks';
const Example: React.FC = () => {
const time = useListenTime();
const { setTimer} = useTimer();
return (
<div>
<p>My time: {time.timer1}</p>
<button onClick={() => setTimer(10, { name: 'timer1', observe: true, listen: true })}>Button</button>
</div>
);
};
timerSettings({ ... });
name | type | default | what`s doing |
---|---|---|---|
const { on } = useTimer();
on((event: TTimerEvent) => {
...
});
This function listens for the events of adding and deleting messages. Data contains: ...