
Security News
Free Certified Patch for Critical Rails Active Storage Vulnerability
Socket has released a free Certified Patch for a critical Rails Active Storage vulnerability, giving developers time to upgrade to a secure Rails version.
react-jitter
Advanced tools
React Jitter is a developer tool to help you understand why your React components re-render. It pinpoints the exact hooks and values that have changed, so you can optimize your application''s performance with precision.
Unnecessary re-renders are a common source of performance issues in React applications. When a component re-renders, it can be difficult to trace the root cause. Was it a state change? A new prop value? A context update? React''s developer tools can tell you that a component re-rendered, but not always why.
Existing tools like why-did-you-render require you to manually whitelist the hooks and components you want to track. This is impractical in large codebases where you want to monitor everything without tedious configuration. Others, like react-scan, are excellent for a high-level overview but don''t pinpoint the exact cause of a re-render. Even the official React Profiler can be frustrating when it reports anonymous hooks or contexts.
React Jitter solves these problems by instrumenting your code at build time with a lightweight SWC plugin. This approach has minimal performance overhead and requires no changes to your component code. It tells you the exact hook that caused a re-render and shows you the previous and current values so you can see exactly what changed.
npm install --save-dev react-jitter
React Jitter is designed to be used during development only. You must ensure that both the SWC plugin and the runtime are disabled in your production builds to prevent instrumenting your production code.
In next.config.js, conditionally add the plugin and its configuration based on the environment:
const isDevelopment = process.env.NODE_ENV === "development";
const nextConfig = {
swcMinify: true,
experimental: {
swcPlugins: isDevelopment
? [
[
"react-jitter/plugin-swc",
{
// An array of hooks to ignore. For example, `["useSelector"]`.
ignoreHooks: [],
// An array of glob patterns for files to exclude from instrumentation.
// By default, `**/node_modules/**` is excluded.
exclude: [],
// When true, the arguments of a hook will be captured as strings
// and included in the `onHookChange` callback. This is disabled
// by default because it can significantly increase the bundle size,
// especially if hooks receive large objects or functions as arguments.
includeArguments: false,
},
],
]
: [],
},
};
module.exports = nextConfig;
.swcrcSince .swcrc is a static JSON file, you cannot use logic within it. You should use separate build scripts or a JavaScript-based configuration file (e.g., swc.config.js) to apply different SWC configurations for your development and production environments.
Once the plugin is configured, you need to initialize the runtime in your application. In your main application file (e.g., _app.tsx in Next.js), ensure the call is only made in development:
// In your app's entry file (e.g., _app.tsx)
import { reactJitter } from "react-jitter/runtime";
if (process.env.NODE_ENV === "development") {
reactJitter({
enabled: true,
// This function will be called whenever a hook's value changes.
onHookChange: (change) => {
console.log("Hook changed:", change);
},
});
}
You can also change enabled and onHookChange at runtime from your browser's developer console. This is useful for temporarily disabling logging or changing the callback behavior without a full page reload.
// Disable React Jitter
window.reactJitter.enabled = false;
// Re-enable React Jitter
window.reactJitter.enabled = true;
// Change the onHookChange callback
window.reactJitter.onHookChange = (change) => {
if (change.unstable) {
console.warn("Unstable hook value:", change);
}
};
Modern bundlers will tree-shake the import and the function call from your production build, so it will have zero performance impact.
The reactJitter function accepts a single onHookChange callback that receives a change object whenever a hook''s value changes.
Here is an example of the change object when an unstable object is detected:
{
"hook": "useUser",
"file": "/src/components/UserProfile.tsx",
"line": 12,
"offset": 18,
"scope": {
"name": "UserProfile",
"file": "/src/components/UserProfile.tsx",
"line": 8,
"offset": 1
},
"unstable": true,
"unstableKeys": ["address"],
"changedKeys": [],
"previousResult": {
"id": "user-123",
"address": { "street": "123 Main St" }
},
"currentResult": {
"id": "user-123",
"address": { "street": "123 Main St" }
}
}
In this case, the address object was re-created, causing an unstable reference even though its contents are the same.
React Jitter is composed of two parts:
One of the most common causes of unnecessary re-renders is "unstable" objects and functions that are re-created on every render. react-jitter helps you identify these issues by tracking when a value''s reference changes and reporting it to you.
react-jitter detects React components using a set of heuristics. It looks for functions that either use hooks or return JSX, and whose names start with a capital letter. While this covers most common cases, it may not detect all components reliably, especially if you use less common patterns for defining components.
Contributions are welcome! Please open an issue or submit a pull request if you have any ideas for improvement.
This project is licensed under the MIT License.
FAQs
A developer tool for debugging React performance issues caused by hook changes and component re-renders.
The npm package react-jitter receives a total of 13,053 weekly downloads. As such, react-jitter popularity was classified as popular.
We found that react-jitter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
Socket has released a free Certified Patch for a critical Rails Active Storage vulnerability, giving developers time to upgrade to a secure Rails version.

Security News
/Threat Research
A malicious Ruby gem runs a credential-stealing worm during installation, poisons AI coding tools, and can wipe files when a stolen GitHub token is revoked.

Security News
GitHub is tightening GitHub Actions security with new restrictions on privileged pull request workflows. Here's what changes and how maintainers are affected.