
Product
Introducing Socket MCP for Claude Desktop
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
react-proxy
Advanced tools
A generic React component proxy useful for hot reloading.
Intended to be used from hot reloading tools like React Hot Loader.
If you’re an application developer, it’s unlikely you’ll want to use it directly.
You will need something like react-deep-force-update to re-render the component tree after applying the update.
import React, { Component } from 'react';
class ComponentVersion1 extends Component {
render() {
return <div>Before hot update.</div>;
}
}
class ComponentVersion2 extends Component {
render() {
return <div>After hot update.</div>;
}
}
Without React Proxy:
const rootEl = document.getElementById('root');
React.render(<ComponentVersion1 />, rootEl);
// Will reset state and kill DOM :-(
React.render(<ComponentVersion2 />, rootEl);
With React Proxy:
import React from 'react';
import { render } from 'react-dom';
import createProxy from 'react-proxy';
import deepForceUpdate from 'react-deep-force-update';
// Create a proxy object, given the initial React component class.
const proxy = createProxy(ComponentVersion1);
// Obtain a React class that acts exactly like the initial version.
// This is what we'll use in our app instead of the real component class.
const Proxy = proxy.get();
// Render the component (proxy, really).
const rootInstance = render(<Proxy />, rootEl);
// Point the proxy to the new React component class by calling update().
// Instances will stay mounted and their state will be intact, but their methods will be updated.
proxy.update(ComponentVersion2);
// Force-update the whole React component tree.
// Until React provides an official DevTools API to do this,
// you should keep the reference to the root instance(s).
deepForceUpdate(rootInstance);
This will work with React Native when facebook/react-native#2985 lands.
For now, you can keep using 1.x.
React.createClass()
) and modern (ES6 classes) stylecreateClass()
autobinding and modern autobind-decorator
displayName
toString()
of methodssetInterval
or setTimeout
are updatedautobind-decorator
causes its identity to changenpm install
npm run test:watch
MIT
FAQs
Proxies React components without unmounting or losing their state.
The npm package react-proxy receives a total of 138,015 weekly downloads. As such, react-proxy popularity was classified as popular.
We found that react-proxy 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.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.