Ternary condition in ES6 destructuring object

Viewed 6182

I wrote a stateless function, in this function I use a destructuring object declaration, but one of my variables has conditions. I wrote it with a ternary condition. but I cannot declare it in the destructuring assignment structure.

This is my declaration:

const {
  data: { result: { total: total } = {} },
  tags: { result: { categoryFilter: { Title: title } = {} } = {} }
} = props;

const pageNo = props.filters.pageno
  ? props.filters.pageno - 1
  : 0;
2 Answers
Related