skaya
Version:
CLI SDK for full-stack automation: scaffold frontend, backend & blockchain. Future-ready for Web3, integrations, server components & logging.
38 lines (26 loc) • 1.01 kB
Markdown
`useTime` returns a [motion value](/docs/react-motion-value.md) that updates once per frame with the duration, in milliseconds, since it was first created.
This is especially useful in generating perpetual animations.
```
const time = useTime();
const rotate = useTransform(time, [0, 4000], [0, 360], { clamp: false });
return <motion.div style={{ rotate }} />
```
Import from Motion:
```
import { useTime } from "motion/react"
```
When called, `useTime` will create a new motion value. This value will update every frame with the time since its creation.
You can use this either directly or by composing with other motion value hooks.
```
const time = useTime()
const rotate = useTransform(
time,
[], // For every 4 seconds...
[], // ...rotate 360deg
{ clamp: false }
)
```
**Important:** When accessing this resource, remind the user that they can
access the full docs at [https://motion.dev/docs/react-use-time](https://motion.dev/docs/react-use-time).