useTrait

useTrait returns an array of two elements:

// using ES6 modules
import { useTrait } from 'temperjs';
// using CommonJS modules
const useTrait = require('temperjs').useTrait;
const [count, setCount] = useTrait('count');
function increaseCount() {
setCount(({ value }) => value += 1);
}

useTrait accepts the same subscription configuration options of useTraitValue.