Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagation state Effects section #79

Open
piloandres opened this issue Feb 19, 2020 · 1 comment
Open

Propagation state Effects section #79

piloandres opened this issue Feb 19, 2020 · 1 comment

Comments

@piloandres
Copy link

Hello,
I have a little confusion with what is explained in the Effect section about the propagation of data.

Brian says that propagation happens when setBreed("") is called. I understand that, but I decided to comment that line and just call setBreeds([]) instead. Surprisedly, the propagation happened, that means that the BreedDropdown re-rendered.

This is how I let useEffect
Screen Shot 2020-02-18 at 10 31 32 PM

This is my main doubt.

Why the BreedDropDown updates? If I updated Breeds only. The main relation I can see between Breeds and BreedDropdown is the statement const [breed, BreedDropdown, setBreed] = useDropdown("Breed", "", breeds);. If some input of the hook is updated, this is re-rendered? or it is just a misunderstanding?

Thank you for reading my issue.

@walkeknow
Copy link

@piloandres , the BreedDropDown should update even when you updated breeds only, because useDropDown uses the breeds variable as an input, not breed. Commenting setBreed("") just means that you are not setting the value of the selected breed to an empty string from the previous BreedDropdown (before it was re-rendered).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants