+ Start a Discussion
Balajee SelvarajBalajee 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.
GhanshyamChoudhariGhanshyamChoudhari
refer this repository  https://github.com/pozil/sfdc-lightning-component-event-playground 
Shivdeep KumarShivdeep Kumar
Hi,
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,
 
// create a attribute in component A
<aura:attribute name="onclick" type="aura:action"/>

// component B
<aura:component>

// component A
<aura:component onclick="{!c.refresh}"/>

<aura:component/>

// Controller
refresh : function(component, event, helper) {
    var action = cmp.get('c.myController');
    action.setCallback(cmp,
        function(response) {
            var state = response.getState();
            if (state === 'SUCCESS'){
                $A.get('e.force:refreshView').fire();
            } else {
                 //do something
            }
        }
    );
    $A.enqueueAction(action);
}
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
Ramakrishna Reddy GouniRamakrishna Reddy Gouni
you can call doinit method again by using aura method from child component. i hope if you call doint(on load methods) i.e works for you. 
Alain CabonAlain Cabon
Hi,

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
Ravi Dutt SharmaRavi Dutt Sharma
Components communicate with each other through events. There are 2 types of events in Lightning - component event and application events. If you want to communicate from child component to parent component, use a component event. If you want to broadcast an information to the entirie application, use an application event.

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