Desc order is not working while asc is working in vidly

here is my code
lass TableHeader extends Component {

raiseSort = path => {

const sortColumn = { ...this.props.sortColumn };

if (sortColumn.path === path)

  sortColumn.order = sortColumn.order === "asc" ? "desc" : "asc";

else {

  sortColumn.path = path;

  sortColumn.order = "asc";

}

this.props.onSort(sortColumn);

};

class Movies extends Component {

state = {

movies:[],

deleted: [],

genres:[],

pageSize: 4,

currentPage:1,

sortColumn: { path: "title", order: "asc" }

};
handleSort = sortColumn => {

this.setState({ sortColumn });

};
const sorted = _.orderBy(filtered, [sortColumn.path], [sortColumn.order]);

const movies = paginate(sorted,currentPage,pageSize)

Have the exact same problem, don’t know how to solve it … If anyone has the solution please share it :pensive:

I tried to console.log to see the problem, i see that before the “if” in the tableHeader.jsx the sortColumn.path is undefined, so when you never actualy enter the “if” and always go to the “else”, i guess the problem comes from some props issue ?

Ok found the error, the issue was in movies.jsx :

<MoviesTable

          movies={movies}

          onLike={this.handleLike}

          onDelete={this.handleDelete}

          onSort={this.handleSort}

          sortColumn={sortColumn}          // had this.sortColumn, instead of sortColumn

        />
1 Like

Hi All,

It works well for me.

Regards,
Thang