![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
use-effect-x
Advanced tools
Most of the times we need to respond to updates in our components, where we need to compare previous values and current values. Remember we had the same thing with componentDidUpdate in class based components earlier. useEffect today are not capable to do so out of the box. you need to put in extra effort to get the previous and current values.
We will focus on the function components now, as they are the most prominent way of developing components today.
In functional components we typically make use of usePrevious custom hooks. That definetly works. But, you need to do extra work of adding usePrevious hooks for individual items in useEffect dependency.
What if we have the access of previous and new values in useEffect callback also, so that we dont have to do that extra work of writing usePrevious hooks.
So there you go, I try to solve the problem using useEffect alternative which provides extra info about the dependencies , tells you what changed, previous values, current values and first run for the starters
If you use yarn. Run
yarn add use-effect-x
If you use npm. Run
npm i use-effect-x
import { useEffectX } from 'use-effect-x';
export default function App() {
const [countA, setCountA] = React.useState(0);
const [countB, setCountB] = React.useState(0);
useEffectX(
({ changedItem }) => {
// Here you have complete access to what changed
console.log('changed Item', changedItem);
// your logic if you want to check for count
console.log(
`count ${changedItem[0]?.changed ? 'changed' : 'not changed'} from ${
changedItem[0]?.previous
} to ${changedItem[0]?.next}`
);
},
[countA, countB]
);
return (
<div className="App">
countA -> {countA}
countB -> {countB}
<button
onClick={() => {
setCountA(countA + 1);
}}
>
Change count A
</button>
<button
onClick={() => {
setCountB(countB + 1);
}}
>
Change count B
</button>
</div>
);
}
FAQs
An alternative to useEffect which provide extra info to work with updates
The npm package use-effect-x receives a total of 59 weekly downloads. As such, use-effect-x popularity was classified as not popular.
We found that use-effect-x demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.