Skip to content

useRound

Category
Export Size
67 B
Package
@reause/math
Last Changed
5 days ago

Reactive Math.round

Demo

Usage

tsx
import { 
useRound
} from '@reause/math'
const
result
=
useRound
(20.49) // 20

value is a plain read-only number. Re-render with a new value — e.g. from useState — and the hook recomputes:

tsx
import { 
useRound
} from '@reause/math'
import {
useState
} from 'react'
const [
value
,
setValue
] =
useState
(20.49)
const
result
=
useRound
(
value
) // 20
setValue
(-20.51) // triggers a re-render

Type Declarations

ts
export function useRound(value: number): number

Source

Source · Demo · VueUse

Contributors

hairyf

Changelog

v0.1.0 on
57cb0 - feat(math): add useRound (#198)

Released under the MIT License. v0.1.8