📅  最后修改于: 2022-03-11 15:01:37.858000             🧑  作者: Mango
// myContainer.js
import React, { useState } from 'react'
import MyChild from 'some/path/myChild'
function MyContainer() {
const [name, setName] = useState('foo')
return (
)
}
export default MyContainer
// myChild.js
import React, { useCallback } from 'react'
function MyChild({ name, onNameChange }) {
const handleInputChange = useCallback(event => {
onNameChange(event.target.value)
}, [onNameChange])
return (
The name is: {name}
)
}
export default MyChild