react hooks and setInterval

前端 未结 4 1449
孤独总比滥情好
孤独总比滥情好 2021-02-06 08:14

Is there any alternative to just keeping a \"clock\" in the background to implement auto-next (after a few seconds) in carousel using react hooks?

The custom react hook

4条回答
  •  轮回少年
    2021-02-06 08:38

    You could use useTimeout hook that returns true after specified number of milliseconds.

    • https://github.com/streamich/react-use/blob/master/docs/useTimeout.md

提交回复
热议问题