当前位置: 首页 > 知识库问答 >
问题:

太多的重放。React限制呈现的数量以防止无限循环。?

公羊雅达
2023-03-14

呈现以下组件时出现错误:

太多的重放。React限制呈现的数量以防止无限循环。?

import React, { useState } from 'react';
     
function My() {
  const [NAME, setValue_] = useState([{name:"",lname:""}]);  //      usestate
  let arr = [{ name: "man", lname: "Kumar" }];    //.......creating array for passing to set the value for State..
      
  setValue_(arr); //............passing array to Update data......

  console.log(NAME);   //..........Want to see updated Data....
        
  return(<> </>) //............... i didn't return anything........
}

共有1个答案

商佑运
2023-03-14
import React, { useState } from 'react';
     
function My() {
  const [name, setName] = useState([{ name: "man", lname: "Kumar" }]); 
        
  return(<>helloworld</>)
}
 类似资料: