父组件获取子组件值的四种情况
子组件获取父组件的值都知道,最基本的就是通过props传值即可,同样也可以使用context
由于是单向数据流,那么父组件是怎么获取子组件的值呢。
对类组件,函数组件都进行梳理
均为类组件
使用 ref
import React, { Component } from 'react';
import ChildClass from './ChildClass';
class FatherClass extends Component {
constructor(props) {
...
youngle316.hashnode.dev3 min read