1.0.3 • Published 2 years ago

state-package-js v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Use

  • state is similar to react's useState but some things change
  • see below an example>

create a fruit basket

// start a new state
const [fruits, setFruits] = new useState([]);

// change state value
setFruits(["banana", "apple"]);

// see state value
console.log(fruits()); // [ 'banana', 'apple' ]

delete a state

// start a new state
const [fruits, setFruits, fruitsDestroy] = new useState([]);

// change state value
setFruits(["banana", "apple"]);

// see state value
console.log(fruits()); // [ 'banana', 'apple' ]

// destroy state
fruitsDestroy();

// see state value
console.log(fruits()); // undefined

implementation of a counter using state with blessed