You need to sign in to do that
Don't have an account?
Balajee Selvaraj
Lightning component refresh from child component to parent component.
Hi All,
I am having 2 Lightning Component.
Lightning Component - A having Button.
If I am clicking on the button in Lightning Component - A. Lightning Component - B should refresh.
Do you have any sample codes please post below.
I am having 2 Lightning Component.
Lightning Component - A having Button.
If I am clicking on the button in Lightning Component - A. Lightning Component - B should refresh.
Do you have any sample codes please post below.
I can not see full detail about what you need but for two component there is two scenario :
1- If Component A is child of component B thn,
It will refresh the component B.
OR
you can use the component type event, which will fire from component A and refresh the component B. in this case event handler will be used on parent component and register handler will used on child component.
If Component A and component B has no relation OR you want to refresh the child component from parent component then use Application event and do similar as above (as per your requirement).
Thanks
Shivdeep
The standard way is to use an event (component or application event). The handler in parent can perform the refresh.
Documentation: Although Aura.Action works for passing an action handler to a child component, we recommend registering an event in the child component and firing the event in the child’s controller instead. Then, handle the event in the parent component. The event approach requires a few extra steps in creating or choosing an event and firing it but events are the standard way to communicate between components.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_attr_types_aura_action.htm
The reference article by Philippe Ozil: Lightning Inter-Component Communication Patterns
https://developer.salesforce.com/blogs/developer-relations/2017/04/lightning-inter-component-communication-patterns.html
Here is an example of component event given by Salesforce:
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_component_example.htm