value
Property to get the current value of the Signify state.
Description
The value
property provides direct access to the current state value without subscribing to changes. This is useful for reading the state outside of React components or when you need the current value without triggering re-renders.
Input/Output
Input | Type | Description |
---|---|---|
None | - | Read-only property access |
Output | Type | Description |
---|---|---|
Returns | T | Current state value |
Example
typescript
import { signify } from 'react-signify';
const sCounter = signify(10);
const sUser = signify({ name: 'John', age: 25 });
// Get current values
console.log(sCounter.value); // 10
console.log(sUser.value); // { name: 'John', age: 25 }
// Use in event handlers
const handleSubmit = () => {
const currentUser = sUser.value;
console.log('Submitting:', currentUser.name);
};
// Check value before updating
const increment = () => {
if (sCounter.value < 100) {
sCounter.set(sCounter.value + 1);
}
};