Skip to content

useAbs

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

Reactive Math.abs

Demo

Usage

tsx
import { 
useAbs
} from '@reause/math'
const
result
=
useAbs
(-23) // 23

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

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

Type Declarations

ts
export function useAbs(value: number): number

Source

Source · Demo · VueUse

Contributors

hairyf

Changelog

v0.1.0 on
c48ca - feat(math): add useAbs (#62)

Released under the MIT License. v0.1.8