![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.
side-effect-manager
Advanced tools
A tiny library to encapsulate side effects in a compact, reusable and testable style.
A tiny library to encapsulate side effects in a compact, reusable and testable style.
npm add side-effect-manager
Conventionally we write side effects like this:
class MyClass {
constructor() {
this.handleResize = () => {
console.log("resize");
};
window.addEventListener("resize", this.handleResize);
}
destroy() {
// cleanup side effects
window.removeEventListener("resize", this.handleResize);
}
}
This code style is scattered and hard-to-follow. The side effect handler has to be exposed to this
which leaves us many unwanted and uncompressible properties.
With side-effect-manager
we may write the same logic like this instead:
import { SideEffectManager } from "side-effect-manager";
class MyClass {
constructor() {
this.sideEffect = new SideEffectManager();
this.sideEffect.add(() => {
const handleResize = () => {
console.log("resize");
};
window.addEventListener("resize", handleResize);
return () => window.removeEventListener("resize", handleResize);
});
// or simply like this
this.sideEffect.addEventListener(window, "resize", () => {
console.log("resize");
});
}
destroy() {
this.sideEffect.flushAll();
}
}
Not only the code is more compact and readable, variables can now be compressed as they are not properties.
Add a side effect:
sideEffect.add(() => {
const subscription = observable$.subscribe(value => {
console.log(value);
});
return () => subscription.unsubscribe();
});
There are also sugars for addEventListener
, setTimeout
and setInterval
.
sideEffect.setTimeout(() => {
console.log("timeout");
}, 2000);
Adding a side effect returns a disposerID
which can be used to remove
or flush
a side effect.
const disposerID = sideEffect.addEventListener(window, "resize", () => {
console.log("resize");
});
// Remove the side effect without running the disposer callback
sideEffect.remove(disposerID);
// Remove the side effect then run the disposer callback
sideEffect.flush(disposerID);
A disposerID
can also be set deliberately. Side effects with the same ID will be flushed before adding a new one.
function debounce(handler, timeout) {
sideEffect.setTimeout(handler, timeout, "my-timeout");
}
FAQs
A tiny library to encapsulate side effects in a compact, reusable and testable style.
We found that side-effect-manager 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.