The skill of the future is not 'AI', but 'Focus'
Link: carette.xyz/posts/focus_will_b…
Discussion: news.ycombinator.com/item?id=4…
The skill of the future is not 'AI', but 'Focus'
Don't let AI erode your focus.Journey into a wild pointer
The skill of the future is not 'AI', but 'Focus'
Link: carette.xyz/posts/focus_will_b…
Discussion: news.ycombinator.com/item?id=4…
Don't let AI erode your focus.Journey into a wild pointer
Omani officials stated that the indirect talks are 'gaining momentum' after Tehran and Washington agreed to establish technical delegations to draft a potential replacement for the Obama-era JCPOAthecradle.co
The United Nations Relief and Works Agency for Palestine Refugees (UNRWA) said on Saturday that Palestinians in Gaza are besieged, bombarded, and starved once again due to the Israeli closure of the Strip’s crossings for the seventh consecutive weekDAILY YEMEN
China and Egypt held their first joint air force drill, Chinese media reported on Sunday, Anadolu reports. Named “Eagles of Civilization 2025,Middle East Monitor
Things Zig comptime won't do
Link: matklad.github.io/2025/04/19/t…
Discussion: news.ycombinator.com/item?id=4…
Es el disco de Odín. Tiene un solo lado. En la tierra no hay otra cosa que tenga un solo lado.matklad.github.io
Following the second round of U.S.-Iran nuclear talks, some reports have been circulated that Iranian Foreign Minister Abbas Araghchi is slated to deliver a speech at the International Nuclear Conference in the U.S.Iran Press
Norovirus outbreak sickens 140 at hotel in Japan's Hokkaido-english.news.cn
Healthy soil is the hidden ingredient
Link: nature.com/articles/d41586-025…
Discussion: news.ycombinator.com/item?id=4…
Around 60% of the European Union’s soils are considered unhealthy, but geographer Jesús Rodrigo Comino is determined to help change that in his native Spain.Forrester, Nikki
You can follow us in other languages. Visit our website for more information wordsmith.social/protestation/…
Previously, the Iranian Football Federation announced plans for a friendly encounter with Russia on October 6TASS
Al Mayadeen's correspondent says at least people were martyred in the latest US aggression, as the UN Secretary-General expresses concern over the US airstrikes.Al Mayadeen English (US forces launch massive aggression on several areas in Yemen)
Cairo, Apr 17 (Prensa Latina) The Egyptian website, the Hispano-Arab League, criticized the United States’ campaign against Cuba, including attacks on Cuba’s medical cooperation with ot…Network in Defense of Humanity-Cuba
Why on Earth is OpenAI buying Windsurf?
Link: theahura.substack.com/p/tech-t…
Discussion: news.ycombinator.com/item?id=4…
$3 billion seems high to me. Google is on a warpath. And Apple shoots itself in the foot, twice.theahura (12 Grams of Carbon)
The four-day meetings of the Arab Parliament kicked off in the Iraqi capital, Baghdad, with the presence of 60 representatives of the parliaments of the Arab countries.www.saba.ye
Alipay debuts PL1 palm biometric terminal with dual-mode authentication, targeting secure, touch-free payments across Hangzhou and beyond.Ken Macon (Reclaim the Net)
“This move was taken on the eve of Easter, which makes it particularly significant and symbolic, as Easter is equally revered by three fraternal nations - Belarus, Russia and Ukraine - as a time of peace, humanism and renewal,” the press service said…Belarusian Telegraph Agency
Pyongyang, April 20 (KCNA) — Shortly ago, the present U.S. administration took a measure to ease the “regulations” that had been obstacles to the export of homemade military equipment.Dermot Hudson (KFAUK.com)
The Shock Doctrine is Canadian author and social activist Naomi Klein's companion piece to her popular 2007 book of the same name. In short, the shock doctri...YouTube
React's component architecture is powerful, but passing data through multiple levels of components can quickly become cumbersome. This is where the Context API and the useContext hook come in - they provide an elegant solution to share data across your component tree without the hassle of prop drilling. In this blog post, we'll explore what Context API is, why you should use it, and how to implement it effectively in your React applications.
The React Context API is a built-in feature that allows you to share data (state, functions, values) across your component tree without having to manually pass props through every level. It effectively solves the "prop drilling" problem, where you need to pass data through many layers of components that don't actually need the data themselves but simply pass it down to lower components.
Think of Context as a direct communication channel between a provider (a parent component that supplies the data) and consumers (any descendant components that need access to that data).
Passing props through multiple component layers creates unnecessary coupling and makes your code harder to maintain. Context lets you make data directly available to any component that needs it.
Unlike external libraries such as Redux, the Context API is built into React and requires minimal setup. No need for actions, reducers, or managing a separate store—just create a context and a provider.
By centralizing shared state and avoiding unnecessary prop chains, your component hierarchy becomes cleaner and more understandable, making your application easier to debug and maintain.
Being part of React itself means you don't need additional dependencies, keeping your bundle size smaller compared to external state management solutions.
Context API is perfect for:
However, it's not meant to replace all prop passing or state management. Use it for data that is truly global or needs to be accessed by many components at different levels.
Let's walk through the implementation of Context API with a simple example for managing user authentication:
First, we create a context object:
// UserContext.js
import React, { createContext } from 'react';
const UserContext = createContext();
export default UserContext;
Next, we create a provider component that will manage the state:
// UserProvider.js
import React, { useState } from 'react';
import UserContext from './UserContext';
const UserProvider = ({ children }) => {
const [user, setUser] = useState(null);
// Login function to update user state
const login = (userData) => {
setUser(userData);
};
// Logout function to clear user state
const logout = () => {
setUser(null);
};
// Memoize the context value to prevent unnecessary re-renders
const value = React.useMemo(() => ({
user,
login,
logout
}), [user]);
return (
<UserContext.Provider value={value}>
{children}
</UserContext.Provider>
);
};
export default UserProvider;
In your main file (e.g., index.js
or App.js
):
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import UserProvider from './context/UserProvider';
ReactDOM.render(
<UserProvider>
<App />
</UserProvider>,
document.getElementById('root')
);
Now, any component in your app can access the user data and functions:
// Profile.js
import React, { useContext } from 'react';
import UserContext from '../context/UserContext';
const Profile = () => {
const { user, logout } = useContext(UserContext);
return (
<div>
{user ? (
<>
<h2>Welcome, {user.name}</h2>
<button onClick={logout}>Logout</button>
</>
) : (
<p>Please log in to view your profile</p>
)}
</div>
);
};
export default Profile;
To ensure optimal performance when working with Context, follow these best practices:
Always use useMemo
to memoize your context values to prevent unnecessary re-renders:
const value = useMemo(() => ({ user, setUser }), [user]);
Instead of a single mega-context, create multiple contexts for different concerns (e.g., separate contexts for theme, authentication, app settings):
// ThemeContext.js
const ThemeContext = createContext();
// UserContext.js
const UserContext = createContext();
// In your app:
<ThemeProvider>
<UserProvider>
<App />
</UserProvider>
</ThemeProvider>
Keep state update logic in the provider and pass update functions down through context:
const UserProvider = ({ children }) => {
const [user, setUser] = useState(null);
const updateUserProfile = (updates) => {
setUser(prev => ({ ...prev, ...updates }));
};
// Pass the update function in context
const value = useMemo(() => ({
user,
updateUserProfile
}), [user]);
return (
<UserContext.Provider value={value}>
{children}
</UserContext.Provider>
);
};
Not all state needs to be in context. Keep temporary or component-specific state local:
const ProfileForm = () => {
const { user, updateUserProfile } = useContext(UserContext);
const [formData, setFormData] = useState(user);
const handleSubmit = (e) => {
e.preventDefault();
updateUserProfile(formData); // Only update context when form is submitted
};
// ...rest of component
};
Feature | Context API | Redux |
---|---|---|
Setup Complexity | Simple, minimal boilerplate | More complex, requires actions/reducers |
Built-in | Yes | No (external library) |
Performance | Good for small/medium apps | Better for large/complex apps |
Code Readability | High | Can become verbose |
Debugging | Limited tools | Excellent dev tools |
Learning Curve | Low | Moderate to high |
The Context API is ideal for:
Redux might be better for:
The Context API and useContext hook provide a powerful, built-in solution for state management in React applications. By eliminating prop drilling and centralizing your shared state, you can write cleaner, more maintainable code with minimal setup.
While it's not a replacement for all state management solutions, Context API is perfect for handling global data like user authentication, themes, and application settings. When used following the best practices outlined above, it can significantly simplify your React application's architecture while maintaining good performance.
Start implementing Context in your React applications today, and experience the benefits of streamlined state management!#webdev #javascript #react #frontend #software #coding #development #engineering #inclusive #community
Understanding React's Context API React's component architecture is powerful, but passing...Bholu Tiwari (DEV Community)
On Saturday night, at least 29 US airstrikes targeted Yemen, resulting in multiple casualties and prompting the UN to issue warnings over the safety of civilians.The Palestinian Information Center
In a virtual hearing on human rights with the European Parliament, Cuban opposition activists Rosa María Payá and José Daniel Ferrer called for new economic sanctions against their own country, with their historic goal of deepening the suffering of t…Orinoco Tribune - News and opinion pieces about Venezuela and beyond
Our socials: fediverse.blog/~/ActaPopuli/fo…
Santiago, Chile, April 19 (Prensa Latina) Colo Colo, Chile's popular soccer team, celebrates its 100th anniversary today with a celebration overshadowed by the recent deaths of two young men following acts of violence unleashed by their hooligans.Elsy Fors Garzon (Prensa Latina)
You Commit Three Felonies a Day (2013) - kottke.org/13/06/you-commit-th…
In a book called Three Felonies A Day, Boston civil rights lawyer Harvey Silverglate says that everyone in the US commits felonieskottke.org
A 1980s toy robot arm inspired modern robotics - technologyreview.com/2025/04/1…
The tasks taken on by the Armatron aren’t so different from the ones AI is tackling today.Jon Keegan (MIT Technology Review)
On Saturday the Russian Defense Ministry said that the Slavic giant has recovered 246 soldiers in a prisoner exchange with Ukraine in which they will alsoteleSURenglish
They’re low-cost and could be politically beneficial but are of questionable quality for now.Andrew Korybko (Andrew Korybko's Newsletter)
Layered Design in Go
Link: jerf.org/iri/post/2025/go_laye…
Discussion: news.ycombinator.com/item?id=4…
All my investigations are free to read, thanks to the generosity of my readers.Kit Klarenberg (Global Delinquents)
ocram oubliat likes this.
If confirmed, Yehuda Kaploun will be the first Lubavitcher Hassid to fill this senior State Department role. His attacks on the Democrats call into question the image of non-partisanship the Chabad tries so hard to projectJudy Maltz (Haaretz)
Gemma 3 QAT Models: Bringing AI to Consumer GPUs
Link: developers.googleblog.com/en/g…
Discussion: news.ycombinator.com/item?id=4…
The release of int4 quantized versions of Gemma 3 models, optimized with Quantization Aware Training (QAT) brings significantly reduced memory requirements, allowing users to run powerful models like Gemma 3 27B on consumer-grade GPUs such as the NVI…Edouard YVINEC (developers.googleblog.com)
BETHLEHEM / PNN / Amid religious rituals and official reception, the city of Bethlehem marked Holy Saturday — theenglish.pnn.ps
“I am a fan of this network,” Tehran’s top diplomat Abbas Araghchi has admittedRT
Голос Кореи,Voice of Korea,Voz de Corea,صوت كوريا ,Stimme Koreas,공화국,vokwww.vok.rep.kp
In the United States, migrants who were mistakenly recognized as dead began demanding that the authorities restore their legal status, The Washington Post (WP) reports.newsmaker1 newsmaker1 (English News front)
Pretty State Machine Patterns in Rust (2016)
Link: hoverbear.org/blog/rust-state-…
Discussion: news.ycombinator.com/item?id=4…
A computer scientist working in open source towards a more hopeful future.hoverbear.org
Dear Friend of Press Freedom,Here are this week’s top press freedom stories, plus updates on our work at Freedom of the Press Foundation (FPF).Freedom of the Press
Russia launched a precision strike on targets in Sumy using Iskander-M missiles. Find out the details of the operation.Саймон Вествуд (New Eastern Outlook)
Iran’s foreign minister says the latest round of indirect talks with the US yielded progress on principles of a likely deal, but advised great caution.PressTV
Harpal Brar, Chairman of the CPGB-ML, speaks at a conference hosted by the Chinese Academy of Social Sciences in Beijing, on October 14th 2015.A significant ...YouTube
TEHRAN (Tasnim) – Demonstrators took to the streets of major US cities on Saturday in a second wave of protests against President Donald Trump, voicing opposition to his immigration policies, attacks on democratic norms, and cuts to science and healt…Tasnim News Agency
PM Irvin Refugees walk down a road in Gaza surrounded by ruined buildings | (photo by Jaber Jehad Badwan, via Wikimedia) Capital Is Murder Capital was soaked in blood, steeped in urine, and “drippi…INTERNATIONALIST 360°
Follow us on social fediverse.blog/~/ActaPopuli/fo…
You can follow us in other languages. Visit our website for more information wordsmith.social/protestation/…
Our socials: fediverse.blog/~/ActaPopuli/fo…
ocram oubliat likes this.
SANAA, April 19 (YPA) - Yemen's air defenses announced on Saturday that a American MQ-9 Reaper drone was shot down over the airspace of Sanaa provinces.Military spokesman Brig. Gen. Yahiya Sarie, said in a statement that the drone was targeted by a lاحسن (Yemen Press Agency)
Novel color via stimulation of individual photoreceptors at population scale
Link: science.org/doi/10.1126/sciadv…
Discussion: news.ycombinator.com/item?id=4…
The Icelandic Voting System (2024)
Link: smarimccarthy.is/posts/2024-11…
Discussion: news.ycombinator.com/item?id=4…
It’s election season here in Iceland! The election is on Saturday, 30th of November, so next Saturday from when this is written.Smári McCarthy
Electromagnetism as a Purely Geometric Theory
Link: iopscience.iop.org/article/10.…
Discussion: news.ycombinator.com/item?id=4…
As America metaphorically turns its guns on China, Uncle Sam can be sure that any trouble emanating from Europe over Greenland or anything else can…Strategic Culture Foundation
100 Years to Solve an Integral (2020)
Link: liorsinai.github.io/mathematic…
Discussion: news.ycombinator.com/item?id=4…
The integral of sec(x) is well known to any beginners calculus student. Yet this integral was once a major outstanding maths problem. It was first introduced...liorsinai.github.io
Depriving Archbishop Markell of Balti and Falesti of opportunity to fly to Jerusalem for the Holy Fire is manifestation of the anti-people course of the Moldovan authorities, and the international community should pay attention to that and assess Chi…Sputnik International
by Moon of Alabama. They believe it is necessary to destroy the old system before a new, more glorious one can emerge. They know the process will be painful for many, but hope for a favorable outcome on a new trajectory.Réseau International
Die Sozialbeiträge könnten immer weiter steigen. Das ist auch ein Problem für die Wirtschaftsleistung, sagen Experten. Kritik gibt es dabei vor allem am Koalitionsvertrag.
Sozialbeiträge: Experten erwarten steigende Belastung
N. E. Felibata 👽 reshared this.
Which year: guess which year each photo was taken
Link: whichyr.com/
Discussion: news.ycombinator.com/item?id=4…
Guess the year real-world photos were taken. Test your history knowledge with a daily challenge featuring a new set of photos each day.Which Year
Everyone knows your location, Part 2: try it yourself and share the results
Link: timsh.org/everyone-knows-your-…
Discussion: news.ycombinator.com/item?id=4…
It's been more than 2 months now since my first post on the topic of location data sharing between various 3rd parties came out – in case you haven't seen it, you should definitely start from there: Everyone knows your locationHow I tracke…tim (tim.sh)
Russian President Vladimir Putin has announced that an Easter truce will begin at 6 pm Moscow time (3 PM GMT) on Saturday and will last until midnight on SundaySputnik India
The war in Ukraine is not between the defending Ukraine vs the aggressing Russia, but between the aggressing US vs the defending Russia.Eric ZUESSE (Oriental Review)
Wie ungesund ist Zucker wirklich? Ein Blick auf den Stand der Forschung, widersprüchliche Aussagen - und was das für unsere Ernährung bedeutet.
Widersprüchliche Aussagen über Zucker gehen auf ungeklärte Fragen in der Forschung zurück. Doch die Schlussfolgerungen für unseren Alltag sind eindeutiger, als es den Anschein hat.
Zucker: Was die Wissenschaft (noch) nicht weiß | Terra-X-Kolumne
N. E. Felibata 👽 reshared this.
RT sits down with former British diplomat William Mallinson to talk about Moldovan govt preventing Orthodox archbishop from taking part in the Holy Fire pilgrimageOdysee
Our socials: fediverse.blog/~/ActaPopuli/fo…
The Art of Assembly Language (2010)
Link: plantation-productions.com/Web…
Discussion: news.ycombinator.com/item?id=4…
TEHRAN (Tasnim) – Demonstrators took to the streets of major US cities on Saturday in a second wave of protests against President Donald Trump, voicing opposition to his immigration policies, attacks on democratic norms, and cuts to science and healt…Tasnim News Agency
As students protesting the Gaza genocide encounter violent repression, the push to integrate Arab American Studies and Palestine into Ethnic Studies faces censorship and political attacks as well.Khadeejah Khan (Mondoweiss)
MOSCOW, April 20 - RIA Novosti. Four people were killed in the crash of a single-engine aircraft in the U.S. state of Illinois, the Associated Press reported, citing law enforcement officials. "A single-engine plane crashed into a field in central...Pravda EN
The Houthis (Ansar Allah) have released video footage showing the moment an MQ-9 Reaper combat drone of the United States...Anonymous1199 (South Front)
Philip Giraldi- One day we will really all be victimsthealtworld (TheAltWorld’s Newsletter)
An image of the Australian desert illuminates satellite pollution
Link: thisiscolossal.com/2025/04/a-s…
Discussion: news.ycombinator.com/item?id=4…
Stitching together 343 distinct photos, Joshua Rozells illuminates a growing problem of satellites polluting the night sky.Grace Ebert (Colossal)
You can follow us in other languages. Visit our website for more information wordsmith.social/protestation/…
Western media agree that the Easter truce comes as a surprise Rossa Primavera News from the WestAvis Krane (Rossa Primavera International News)
President Donald Trump may be focused on diplomacy with Iran at the moment, but Israel is still contemplating military strikes on Iran’s nuclear program, Reuters reports this morning.Carl Osgood (EIR News)
Yemeni media reported that US warplanes carried out airstrikes on the capital, Sana’a, using high-explosive bombs.admin (Palestine Chronicle)
Havana, April 17 (ACN) Cuban Foreign Minister Bruno Rodriguez denounced on Thursday the indefinite presence of Israeli troops in Lebanese and Syrian territories, an occupation against regional peace efforts.www.cubanews.acn.cu
Frankreichs Hauptstadt will weg vom Auto und gilt weltweit als Vorbild für ambitionierte Verkehrspolitik. Klappt das? Rauf aufs Rad, ab durch Paris.
Verkehrswende: Auf den Straßen von Paris
Birne Helene reshared this.
WASHINGTON (Sputnik) - The US deal with Kiev on natural resources, which is expected to be signed next week, is not tied to the Ukraine ceasefire process, the US State Department said on Saturday.Sputnik Africa
A unique sound alleviates motion sickness
Link: nagoya-u.ac.jp/researchinfo/re…
Discussion: news.ycombinator.com/item?id=4…
A research group led by Takumi Kagawa and Masashi Kato at Nagoya University Graduate School of Medicine has discovered t...NU Research Information
Laith Marouf & Hadi Hotait visit the village of Yahmor in the south of Lebanon, a village that is suffering daily attacks by the Zionists despite being located north of the Litany river; the official line required for disarmament of resistance.Free Palestine TV (FPTV’s Substack)
Don't force your kids to do math
Link: blog.avocados.ovh/posts/how-to…
Discussion: news.ycombinator.com/item?id=4…
Spoiler: you probably shouldn’t. A personal reflection on playful math, shifting passions, and nurturing curiosity.blog.avocados.ovh
ROME, April 18 (Xinhua) -- Italy's leading industrial association Confindustria said Friday that theen.people.cn
Our socials: fediverse.blog/~/ActaPopuli/fo…
TEHRAN, Apr. 19 (MNA) – Moscow and Kyiv exchanged 246 prisoners of war each on Saturday, the largest since the outbreak of the war over three years ago, the Russian Defense Ministry announced.Mehr News Agency
“No one, under the current circumstances, is allowing any humanitarian aid to enter Gaza, and we are not preparing for any such entry.”So said defense minist...YouTube
The International Steering Committee (ISC) of Railroad Workers United passed a resolution to bring home Brother Kilmar Armando Abrego Garcia, a legally protected immigrant and SMART Union member.Railroad Workers United (Labor Today)
Once again we do our best to unpack the recent global reshaping as it happensvanessa beeley (Vanessa Beeley)
US and Iranian officials are engaged in a new round of talks, facilitated by Omani mediation, in hopes of securing a new nuclear and sanctions relief dealthecradle.co
Million-man marches took place in the capital Sana’a and other governorates, carrying the slogan “Steadfast with Gaza in the face of American-Israeli escalation,” affirming “the steadfastness of our position with Gaza, and we will not retreat underDAILY YEMEN
The Palestinian Ministry of Health has warned that 200,000 people with chronic illnesses are at life-threatening risk due to the continued closure of crossings by Israeli forces, which threatens the...Middle East Monitor
The indirect talks between Iran and the United States, mediated by Oman, have concluded in Italy, with reports indicating a constructive atmosphere during the discussions.iranpress.com
2 dead, 9 injured after car rams into crowd in central Philippines-english.news.cn
The lamp with the fire will be delivered to the Cathedral of Christ the Savior in Russia’s capitalTASS