How to use the immutability-helper.update function in immutability-helper

To help you get started, we’ve selected a few immutability-helper 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 owtf / owtf / owtf / webui / src / Report / Report.jsx View on Github external
type = 'selectedGroup';
        } else if (filter_type === 'user_rank') {
            type = 'selectedRank';
        } else if (filter_type === 'owtf_rank') {
            type = 'selectedOwtfRank';
        } else if (filter_type === 'mapping') {
            this.setState({selectedMapping: val});
            return;
        } else if (filter_type === 'status') {
            type = 'selectedStatus';
        }

        let index = this.state[type].indexOf(val);
        if (index > -1) {
            this.setState({
                [type]: update(this.state[type], {
                    $splice: [
                        [index, 1]
                    ]
                })
            });
        } else {
            this.setState({
                [type]: update(this.state[type], {$push: [val]})
            });
        }

    };
github owtf / owtf / owtf / webapp / src / Report / Report.jsx View on Github external
} else if (filter_type === 'status') {
            type = 'selectedStatus';
        }

        let index = this.state[type].indexOf(val);
        if (index > -1) {
            this.setState({
                [type]: update(this.state[type], {
                    $splice: [
                        [index, 1]
                    ]
                })
            });
        } else {
            this.setState({
                [type]: update(this.state[type], {$push: [val]})
            });
        }

    };
github owtf / owtf / owtf / webapp / src / Report / Accordian.jsx View on Github external
success: function() {
                alert.call(this, "Deleted plugin output for " + type + "@" + code);
                for (let i = 0; i < pluginData.length; i++) {
                    if ((pluginData[i]['plugin_type'] === type) && (pluginData[i]['plugin_group'] === group)) {
                        break;
                    }
                }
                let pactive = (pluginData.length !== 1 && i > 0)
                    ? this.state.pluginData[i - 1]['plugin_type']
                    : "";
                pactive = (pluginData.length !== 1 && i === 0)
                    ? this.state.pluginData[i + 1]['plugin_type']
                    : pactive;
                this.setState({
                    pluginData: update(this.state.pluginData, {
                        $splice: [
                            [i, 1]
                        ]
                    }),
                    pactive: pactive
                });
            }.bind(this),
            error: function(xhr, textStatus, serverResponse) {
github owtf / owtf / owtf / webui / src / Report / Accordian.jsx View on Github external
success: function() {
                alert.call(this, "Deleted plugin output for " + type + "@" + code);
                for (let i = 0; i < pluginData.length; i++) {
                    if ((pluginData[i]['plugin_type'] === type) && (pluginData[i]['plugin_group'] === group)) {
                        break;
                    }
                }
                let pactive = (pluginData.length !== 1 && i > 0)
                    ? this.state.pluginData[i - 1]['plugin_type']
                    : "";
                pactive = (pluginData.length !== 1 && i === 0)
                    ? this.state.pluginData[i + 1]['plugin_type']
                    : pactive;
                this.setState({
                    pluginData: update(this.state.pluginData, {
                        $splice: [
                            [i, 1]
                        ]
                    }),
                    pactive: pactive
                });
            }.bind(this),
            error: function(xhr, textStatus, serverResponse) {

immutability-helper

mutate a copy of data without changing the original source

MIT
Latest version published 4 years ago

Package Health Score

74 / 100
Full package analysis