Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-proxy
Advanced tools
Readme
A generic React component proxy used as the new engine by React Hot Loader.
You are looking at the README from the 1.x branch that is widely in use. However we intend to gradually transition projects such as react-transform-hmr
to use 2.x that is being developed in master instead. Currently we mirror all releases on both branches.
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.
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 { createProxy, getForceUpdate } from 'react-proxy';
// 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).
React.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.
// The update() method returns an array of mounted instances so we can do something with them.
const mountedInstances = proxy.update(ComponentVersion2);
// React Proxy also provides us with getForceUpdate() method that works even if the component
// instance doesn't descend from React.Component, and doesn't have a forceUpdate() method.
const forceUpdate = getForceUpdate(React);
// Force-update all the affected instances!
mountedInstances.forEach(forceUpdate);
React.createClass()
) and modern (ES6 classes) styleReact.Component
shouldComponentUpdate
createClass()
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 156,929 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.