-
Notifications
You must be signed in to change notification settings - Fork 59
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
Updating NestedComponents via refs is not working #301
Comments
Hey @pipiobjo, Generally speaking that's not the recommended way of passing updated data to child components, instead you should pass the data down through params. Let's say your parent component also has
That way the Hope that helps, let me know if you need more information. |
Hi @Robert-Frampton thanks for response. Exactly thats the main behaviour as I understood it, but our usecase is slightly different. Yes we could merge that data before, but I would expect a clean way to communicate with a already rendered and instantiated subcomponent. I thought that would be the usecase for using refs? Thanks in advance. |
Hey @pipiobjo, You might want to try configuring the That way the parent component doesn't overwrite anything by mistake. |
Nice works. Maybe a hint in the documentation would be nice that a setter cant be called directly. |
Hi,
I tried to update a Subcomponent via refs as documented here https://metaljs.com/docs/guides/nested-components.html. I'm not sure if I do it right.
Therefore I created a sample project https://github.com/pipiobjo/metal-troubleshooting/tree/master/metal-nested-component
The parent component "NestedComponent" should update the text color of the SubComponent.
Usecase is to create a component to handle a search form and another to handle the results.
In the SoyTemplate of the parent I call the SubComponent via:
And in the JS I call it via
In the browser console I see the setter method is called, but after that its resetted to the default value defined in the State of the SubComponent
Reproduction Steps:
Expected Behaviour
Any help would be great, thanks in advance.
The text was updated successfully, but these errors were encountered: