"You may have an infinite update loop in a component render function" warning in Vue component "You may have an infinite update loop in a component render function" warning in Vue component vue.js vue.js

"You may have an infinite update loop in a component render function" warning in Vue component


You're getting the warning because you're changing the value of data.body within sortBy. This data change will cause the render function to run again. The reason you're not getting an infinite loop is that on the second call to sortBy the data is already sorted which results in no data change to data.body.

The solution is what Jaromanda X mentioned. Using slice will make a copy of the array which means data.body will not change in value, and therefore no re-render will be called.

return data.slice().sort(....