How to use the defaults.stateChoices function in defaults

To help you get started, we’ve selected a few defaults examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dandelany / vector-toy / src / components / App.jsx View on Github external
function getRandomState() {
    // get & hydrate the template which shuffles all the possible choices
    return _.mapValues(_.cloneDeep(DEFAULTS.stateChoices), sampleChoices);
}
github dandelany / vector-toy / src / components / App.jsx View on Github external
_onShuffleOption = (key) => {
        if(!_.has(DEFAULTS.stateChoices, key)) return;
        this.setState(
            {
                [key]: this._getRandomOption(key),
                screenId: +(new Date())
            },
            this._saveStateToUrl
        );
    };
    _onShuffleOptions = () => {
github dandelany / vector-toy / src / components / App.jsx View on Github external
_getRandomOption = (key) => {
        const option = sampleChoices(DEFAULTS.stateChoices[key]);
        if(key === 'domain')
            option.x = option.x || this._xDomainFromYDomain(option.y);
        return option;
    };