Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →If a child component needs to trigger work owned by its parent, define the function in the parent and pass it to the child as a callback prop. The child calls that callback in response to an event; it does not need to reach upward into the parent.
function Parent() {
function handleAction() {
console.log('Action requested by child');
}
return <Child onAction={handleAction} />;
}
function Child({ onAction }) {
return <button onClick={onAction}>Run parent action</button>;
}
React props can carry functions just like other JavaScript values. See Passing Props to a Component and Responding to Events.
As an Amazon Associate I earn from qualifying purchases.
Pass the parent function as a callback prop
When the parent owns an action or state update, it should provide a function prop that gives the child a clear way to request that action. Choose a prop name that describes the event or intent, such as onSave, onChange, or onAction.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteimport { useState } from 'react';
function Parent() {
const [message, setMessage] = useState('Waiting');
function handleChildAction(value) {
setMessage(value);
}
return (
<>
<p>{message}</p>
<Child onAction={handleChildAction} />
</>
);
}
function Child({ onAction }) {
return (
<button onClick={() => onAction('Child clicked')}>
Notify parent
</button>
);
}
Here, the parent owns message and its update function. The child receives onAction and calls it when the button is clicked. This keeps the direction of communication explicit: data and functions flow down through props, while a child can invoke a supplied function to request work from above.
#1 Best Overall
Keep shared state in the closest common parent
If a child action changes data that the parent or a sibling also needs, place that state in their closest common parent. Pass the current value down to the components that display it, and pass handlers down to the components that need to request changes. React describes this as lifting state up.
Do not move every piece of state to the top of the application. State used by only one component can stay local. For information needed by many distant components, React Context may be appropriate, but it is unnecessary for a straightforward parent-child callback.
Call the handler when the event happens, not during render
Pass the function itself to the event prop. Writing onClick={handleClick} gives React a handler to call when the click occurs. Writing onClick={handleClick()} calls the function immediately while rendering and passes its return value instead.
When the callback needs an argument, use a wrapper so the call happens on the event:
Rank #3
<button onClick={() => onAction('Child clicked')}>
Notify parent
</button>
This follows React’s event-handler guidance: pass handlers rather than invoking them during render. See Responding to Events.
Use a ref only when the parent needs an imperative child operation
The phrase “call a function inside a child from the parent” can also mean that the parent must command a method owned by the child. For operations that are inherently imperative—such as focusing an input or scrolling to a node—a ref can expose a small, deliberate child API. React’s useImperativeHandle lets a component customize what its ref exposes.
Rank #4
Refs are an escape hatch, not a replacement for ordinary props and state. If the behavior can be represented declaratively—for example, with an isOpen prop that controls whether a panel is open—prefer that to exposing imperative methods such as open() and close(). See React’s guidance on manipulating the DOM with refs.
Free tools Windows power users keep installed
One-click scans. No signup required.
There is a version difference for custom function components: React 19 allows a component to receive ref as a prop; React 18 and earlier require forwardRef to forward a ref. The current useImperativeHandle reference documents this distinction, and React’s forwardRef reference covers the earlier pattern.
Best Value
Avoid Effects for event callbacks and upward data reporting
Do not add an Effect just to report child data to a parent. If multiple components need the data, let the parent own it and pass values and handlers through props. If the update is caused by a user action, call the callback in that event handler. React explains this in You Might Not Need an Effect.
You also do not need to wrap every callback in useCallback. It caches a function definition between renders, but it is a performance optimization for cases where stable function identity matters, not a requirement for passing a callback prop. See the useCallback reference.
Quick Recap
Choose the communication pattern that matches the job
| Approach | Use it when | Tradeoff |
|---|---|---|
| Callback prop | A child event should ask the parent to perform work or update parent-owned state. | Explicit and declarative; the child can invoke the supplied callback. |
Ref with useImperativeHandle |
The parent needs to command a child capability such as focus or scroll. | Imperative escape hatch; provides a deliberate API but couples the parent to child commands. |
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




