How do I get the newly updated data from react hooks or useEffect?
I loaded the parent components with the title: Shoes
then change the input to "New Shoes"
but the data inside my child components doesn't change, its still "Shoes"
. how do I get it updated?
in the parent components:
<UrlInput
value={url}
title={title}
baseURL={baseURL}
onChange={this.onURLChange}
/>
Child component
const UrlInput = ({title}) => {
const [newTitle, setTitle] = useState(title);
useEffect(() => {
console.log(title)
setTitle(newTitle)
})
return (
);
};