博主使用的React版本为
"react": "17.0.1"
新版需要先在组件内创建ref
refName = React.createRef() //refs新版创建方法,调用直接this.refName
调用演示
//将ref挂载给相应组件
<PicturesWall ref={this.refName } />
//在需要的地方调用该ref
this.refName
调用组件方法
this.refName.current.getFuncName() //调用子组件ref对应的方法