Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react useMemo to render a list

import { useMemo } from 'react';

export default function App() {
  const list = [
    { key: 1, value: 10 },
    { key: 2, value: 20 },
    { key: 3, value: 30 }
  ];

  const renderedList = useMemo(() => (
    list.map(({ key, value }) => (
        <div key={key}>
            {value}
        </div>
    ))
  ), [list]);

  return (
    <div>
        {renderedList}
    </div>
  );
}
COPY
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript new date invalid date dd/mm/yyyy 
Javascript :: jquery option second 
Javascript :: active-class router-link 
Javascript :: react cdn link 
Javascript :: javascript hello world 
Javascript :: javascript change color 
Javascript :: fs fstat 
Javascript :: date now javascript 
Javascript :: difference between undefined and null javascript 
Javascript :: how to create react native app 
Javascript :: javascript read consol input 
Javascript :: dom queryselector 
Javascript :: extract from a string in javascript 
Javascript :: clearing setinterval 
Javascript :: mongoose find multiple conditions 
Javascript :: javascript catch specific error 
Javascript :: jquery values to array 
Javascript :: ant design charts 
Javascript :: javascript press tab key 
Javascript :: cheerio 
Javascript :: node js do request 
Javascript :: why does an array index start at 0 
Javascript :: how to trigger image upload button in from another button react js 
Javascript :: conditional (ternary) operator function parameter 
Javascript :: firebase messaging import script 
Javascript :: alert function in javascript 
Javascript :: declaring constant in jsx 
Javascript :: subtrair datas javascript frontend 
Javascript :: jquery var_dump array 
Javascript :: js delete cookie by name 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =