React State Object updating without setState

React State Object updating without setState

}

class FilterMenu extends Component {
constructor(props){
    super(props);
    this.state = { 
        min: 0,
        max: this.getFormatedPrice(this.props.category_maxPrice,false),
        minValue: '',
        maxValue: '',
        searchTerm: '', 
        data: this.props,
        checkedBoxes: [],
        initialFilters: this.props.filters,
        filters: this.props.filters,   

    }
    this.onInputChange      = this.onInputChange.bind(this);
}

onInputChange(event){

    let substr = event.target.value;
    event.preventDefault();

    {(() => {
        var targetFilter = event.target.id;
        var initialFilterItems = this.initialFilters[targetFilter].items;
        var newFilters = _.extend({}, this.state.filters);
        newFilters[targetFilter].items = initialFilterItems.filter(function(item){
            return item.title.toLowerCase().search(event.target.value.toLowerCase()) !== -1;
        })
        this.setState({ filters: newFilters });
    })()}
}

}

I just want to update "filters" state, which holds some data from "initialFilters". But when I use this.setState({ filters: newFilters }), it's updating "initialFilters" also

Appreciate your support.

reactjs redux

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to implement Redux Saga with ReactJS and Redux?

In this article, I’d like to tell you more about the Redux library and create a simple ReactJS project, where I’ll set up a Redux step by step.

How to implement redux-saga with ReactJS and Redux [TUTORIAL]

In this article, we will go throug theory about state, state management tools like Redux, middleware, Redux Thunk and Redux Saga.

Should I Use Redux?

Starting a new application means drawing out a blueprint of what you want it to look like, and thinking about how you are going to implement whatever you are going to do before you even write any code. As a JavaScript developer, I often find myself questioning whether or not I’ll need to use Redux.

Redux tutorial: 03 - Setup Redux trong ReactJS với Hooks 🎉

Cùng mình khám phá các bước để setup Redux trong một ReactJS App nào ✅ Redux trong Vanilla JS App vs ReactJS App có khác gì nhau ✅ Các bước setup Redux trong Vanilla JS app ✅ Các bước setup Redux trong ReactJS app ✅ Kết nối tới Redux bằng hooks: useSelector(), useDispatch()