【问题标题】:render typescript map in react jsx在反应jsx中渲染打字稿地图
【发布时间】:2022-07-11 22:31:27
【问题描述】:

我有地图对象:

const myMap = new Map<number,string>([
   [10, "text1"],
   [15, "text2"],
   [20, "text3"]
])

寻找如何在 React JSX 中迭代此映射的方法。 提前谢谢你

【问题讨论】:

    标签: reactjs typescript dictionary jsx


    【解决方案1】:
    let nodes: React.ReactNode[] = [];
    myMap.forEach((value, key) => {
        nodes.push(<your jsx>);
    })
    return nodes; // if you are in a component where you want to render
    

    【讨论】:

      猜你喜欢
      • 2021-05-25
      • 2020-08-17
      • 1970-01-01
      • 1970-01-01
      • 2017-12-09
      • 1970-01-01
      • 1970-01-01
      • 2020-06-23
      • 1970-01-01
      相关资源
      最近更新 更多