Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

react 无状态组件怎么调用父组件方法

无状态组件怎么调用父组件中的方法。
无状态组件中有个方法执行完需要调用父组件的一个方法


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

也是通过props传值调用

function ChildrenComponent ( props ) {
    props.fatherFunction()
}

<div>
    <ChildrenComponent fatherFunction={functionName} />
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...