React技巧之中断map循环

正文从这开始~

总览

在React中,中断map()循环:

  1. 在数组上调用slice()方法,来得到数组的一部分。
  2. 在部分数组上调用map()方法。
  3. 遍历部分数组。
export default function App() {
  const employees = [
    {id: 1, name: 'Alice', country: 'Austria'},
    {id: 2, name: 'Bob', country: 'Belgium'},
    {id: 3, name: 'Carl', country: 'Canada'},
    {id: 4, name: 'Delilah', country: 'Denmark'},
    {id: 5, name: 'Ethan', country: 'Egypt'},
  ];

  //