O
O
Olga2018-02-13 13:20:28
React
Olga, 2018-02-13 13:20:28

Where is the error in the function?

There is an error inside the function, I can't figure out what it is

setFilter() {
    const {router} = this.context;
    const {location} = this.props;
    const query = {...location.query};

    if (query.sort_direction === 'desc') {
      delete query.sort_direction;
    } else {
      query.sort_direction = 'desc';
    }
    router.push({...location, query, state: 'REPLACE'});
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2018-02-13
@vshvydky

const query = {...location.query}; // фигня ж , попробуй такое в консоли сделай
const {query} = location;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question