Date Helpers API reference for Date Helpers in Semantic UI's reactivity system calendar Guide

Date Helpers

Date Helpers are methods available on ReactiveVar instances that contain Date objects. These helpers provide a convenient way to update the date value reactively.

now

Sets the value of the ReactiveVar to the current date and time.

Syntax

reactiveVar.now()

Returns

Date - The new Date object representing the current date and time.

Usage

import { ReactiveVar } from '@semantic-ui/reactivity';
const currentTime = new ReactiveVar(new Date());
console.log(currentTime.get()); // Output: current date and time
// After some time...
currentTime.now();
console.log(currentTime.get()); // Output: updated current date and time

Notes

  • The now() method is particularly useful when you need to update a reactive date variable to the current time, such as for timestamps or when refreshing time-based data.
  • Remember that like all ReactiveVar modifications, using now() will trigger any reactive computations that depend on this variable.
  • The returned Date object represents the time at which now() was called, not when it’s later accessed.