Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何防止浏览器重复获取相同的href_Javascript_Reactjs - Fatal编程技术网

Javascript 如何防止浏览器重复获取相同的href

Javascript 如何防止浏览器重复获取相同的href,javascript,reactjs,Javascript,Reactjs,我是react的一名新生,我想编写一个react组件,通过teamId获取团队成员信息 反应代码 从“React”导入React; 从“道具类型”导入道具类型; 从“/pm_user_table”导入UserTable; 从“antd”导入{Form,Modal,Input,Button}; const FormItem=表单项; 类PMBody扩展了React.Component{ 建造师(道具){ 超级(道具); 这个州={ 科特姆:这个。道具。科特姆, 成员名单:[] } } 组件will

我是react的一名新生,我想编写一个react组件,通过teamId获取团队成员信息

反应代码
从“React”导入React;
从“道具类型”导入道具类型;
从“/pm_user_table”导入UserTable;
从“antd”导入{Form,Modal,Input,Button};
const FormItem=表单项;
类PMBody扩展了React.Component{
建造师(道具){
超级(道具);
这个州={
科特姆:这个。道具。科特姆,
成员名单:[]
}
}
组件willmount(){
console.log(“组件安装”);
}
组件将接收道具(下一步){
if(nextrops.curTeam!==this.state.curTeam){
this.setState({curTeam:nextrops.curTeam});
}
}
render(){
设{getFieldProps}=this.props.form;
const teamId=this.state.curTeam;
var myFetchOptions={method:'GET'};
取回(“http://localhost:3001/teamMembers/“+this.state.curTeam,myFetchOptions)
.then(response=>response.json())
。然后(json=>{
this.setState({memberList:json});
}
).catch(函数(){
控制台日志(“错误”);
});
让memberList=this.state.memberList;
const body=成员列表!=''?
:
''
;
返回(
{body}
) 
}
PMBody.PropTypes={
curTeam:PropTypes.string.isRequired,
操作:PropTypes.object.isRequired
}

导出默认PMBody=Form.create({})(PMBody);
您误解了

React调用
render()
,以便在任何更改时更新组件。组件必须是纯的,不应与任何其他内容交互


您应该将其移动到
componentDidMount()

您误解了组件的用途

React调用
render()
,以便在任何更改时更新组件。组件必须是纯的,不应与任何其他内容交互

您应该将其移动到
componentDidMount()