Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesIf a value can be calculated from the current props or state, calculate it during rendering instead of storing it in another useState variable. Keeping both the source and a copy creates two values that must stay synchronized—and the copy can become stale. State is still right for information that changes independently, or when you deliberately want to preserve an initial value.
What “derived state” means in React
Derived state is a value that can be worked out from a component’s current props or other state. For example, if a component has a first name and a last name, the full name is determined by those two values. Storing all three means the component must keep the full name in sync whenever either name changes.
React’s “Choosing the State Structure” guidance recommends calculating information during rendering when it can be derived from props or existing state. The practical test is simple: if the value has no independent source of change, it generally does not need its own state.
Calculate a display value directly
function Greeting({ firstName, lastName }) {
const fullName = firstName + ' ' + lastName;
return <p>Hello, {fullName}!</p>;
}
Here, fullName always reflects the current names. There is no extra setter to call and no second value that can drift out of sync.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Why copying a prop into state goes stale
useState(messageColor) uses messageColor to initialize state on the component’s first render. It does not make that state a live copy of the prop. If the parent later passes a different color, the local state remains unchanged unless your component explicitly updates it.
If the component should always use the parent’s latest value, read the prop directly. If the component is meant to start with a value and then let the user change it independently, name the prop to show that one-time intent, such as initialColor or defaultColor.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Use a prop directly when it remains parent-owned
function Message({ color }) {
return <p style={{ color }}>Message</p>;
}
The parent supplies the current color, so there is no local mirror to keep synchronized.
Initialize local state only when later prop changes should be ignored
function ColorPicker({ initialColor }) {
const [color, setColor] = useState(initialColor);
// The component owns color after initialization.
}
This pattern is intentional only if the component should preserve its own value when initialColor later changes. The prop name makes that contract clearer to callers.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Store an ID, not a copied selected record
For a selected item in a list, keep the item’s ID in state and find the current item from the current list during rendering. Storing a whole item object can leave the selection holding old data after the corresponding list entry changes.
function ItemList({ items }) {
const [selectedId, setSelectedId] = useState(null);
const selectedItem = items.find(item => item.id === selectedId);
return (
<>
<ul>
{items.map(item => (
<li key={item.id}>
<button onClick={() => setSelectedId(item.id)}>
{item.name}
</button>
</li>
))}
</ul>
{selectedItem && <p>Selected: {selectedItem.name}</p>}
</>
);
}
The ID records the user’s selection; the object is derived from the latest list. If the selected ID no longer matches an item, selectedItem is undefined, which the rendering logic can handle.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Do not use an Effect just to keep derived state synchronized
An Effect is for synchronizing with something outside React. If the job is only to transform props or state into a value for rendering, calculate that value in the component instead. Adding an Effect to update one state variable when another changes introduces an extra synchronization step and can leave the rendered value behind its source.
React’s “You Might Not Need an Effect” guidance specifically distinguishes external synchronization from deriving state based on props or other state. Use an Effect when there is an external system to coordinate with; do not add one merely to maintain a redundant copy.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Choose the pattern that matches who owns the value
| Need | Pattern | Trade-off |
|---|---|---|
| The value is determined by current props or state | Calculate during rendering | Always reflects current inputs; computation runs as part of rendering. |
| The calculation is expensive | Consider useMemo |
Can reduce repeated computation; the result is still derived, not independently owned state. |
| The child should always follow the parent | Read the prop directly or use a controlled component | The parent remains the source of truth. |
| The child should preserve only its starting value | Initialize local state from a clearly named initial or default prop |
Later prop changes are intentionally not followed. |
| A new identity should reset all child state | Change the component’s key |
React resets the keyed component tree. |
| A selection refers to an item in a changing collection | Store the item ID and derive the current object | The selected record reflects the current collection. |
| The component must synchronize with a non-React system | Use an Effect where appropriate | Suitable for external synchronization, not routine render calculations. |
When a prop change should reset or adjust local state
Reset the whole child with a key
If a change means the child should start over entirely, give it a different key when its identity changes. React then resets that component’s state tree. This is often clearer than watching a prop in an Effect and manually clearing several state variables.
Use a controlled component when the parent should own the value
If the parent decides the value and the child should display its latest version, pass the value down and report user changes back through a callback. This keeps a single source of truth rather than maintaining a local mirror.
Adjusting state during render is a rare option
React also documents conditionally adjusting a component’s own state during rendering when a prop or other state changes and simpler approaches do not fit. This is an uncommon pattern: it makes data flow harder to follow and must be guarded by a condition so it does not trigger repeated updates. Prefer a controlled design or a key-based reset when either expresses the intended behavior.
Quick Recap
A quick decision checklist
- If the value is fully determined by current props or state, calculate it in the component body.
- If performance is the concern, consider memoizing the calculation rather than storing a separately updated copy.
- If a child should follow the parent’s latest value, use the prop or a controlled component.
- If a child should keep only its starting value, make that intent explicit with an initial/default prop name.
- If changing identity should clear the child’s state, change its key.
- If you are synchronizing with an external system, use an Effect for that synchronization—not merely to copy one React value into another.
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.

