Number Helpers API reference for Number Helpers in Semantic UI's reactivity system hash Guide

Number Helpers

Number Helpers are methods available on ReactiveVar instances that contain numeric values. These helpers provide convenient ways to manipulate and update numeric reactive variables.

increment

Increases the value of the ReactiveVar by a specified amount or by 1 if no amount is provided.

Syntax

reactiveVar.increment(amount)

Parameters

NameTypeDescription
amountNumber(Optional) The amount to increment by. Defaults to 1 if not specified.

Usage

import { ReactiveVar } from '@semantic-ui/reactivity';
const counter = new ReactiveVar(0);
counter.increment();
console.log(counter.get()); // Output: 1
counter.increment(5);
console.log(counter.get()); // Output: 6

decrement

Decreases the value of the ReactiveVar by a specified amount or by 1 if no amount is provided.

Syntax

reactiveVar.decrement(amount)

Parameters

NameTypeDescription
amountNumber(Optional) The amount to decrement by. Defaults to 1 if not specified.

Usage

import { ReactiveVar } from '@semantic-ui/reactivity';
const counter = new ReactiveVar(10);
counter.decrement();
console.log(counter.get()); // Output: 9
counter.decrement(3);
console.log(counter.get()); // Output: 6