D
D
dfv1232018-03-14 09:40:50
React
dfv123, 2018-03-14 09:40:50

Why does an error occur when reading data from state?

https://codesandbox.io/s/zn73y6yylm

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-03-14
@dfv123

Typo and wrong condition. You can fix it like this:

onChange = value => {
  const [from, to] = value;

  const filteredStudios = this.state.studios.filter(studio => 
    studio.price >= from && studio.price <= to
  );

  this.setState({
    studios: filteredStudios,
    from,
    to,
  });
};

Only you are overwriting the filtered state on top of the unfiltered one. I also think this is wrong.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question