📌  相关文章
📜  React 钩子从孩子更新父状态 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:13.445000             🧑  作者: Mango

代码示例1
const EnhancedTable = ({ parentCallback }) => {
    const [count, setCount] = useState(0);
    
    return (
        
    )
};

class PageComponent extends React.Component { 
    callback = (count) => {
        // do something with value in parent component, like save to state
    }

    render() {
        return (
            

count 0

(count should be updated from child)
) } }