
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
configure-should-component-update
Advanced tools
Provides a function to configure React's shouldComponentUpdate() function in a declarative way
Provides a function to build a customized React's shouldComponentUpdate() function in a declarative way.
import React from 'react';
import {configureShouldComponentUpdate} from 'configure-should-component-update';
class Label extends React.Component {
static propTypes = {
text: PropTypes.string,
color: PropTypes.any,
};
render() {
// ...
}
}
configureShouldComponentUpdate(Label, {
props: {
text: (prev, next, { key, props, state, nextProps, nextState }) => a == b,
},
state(prevState, nextState, { props, nextProps }) {
return prevState.pressed === nextState.pressed && !nextProps.disabled;
}
});
Here configureShouldComponentUpdate
function call will create a function in
Label.prototype.shouldComponentUpdate
, which will be shallowly comparing
this.props
with nextProps
and this.state
with nextState
, but in addition to it,
the preconfigured properties like text
will use the corresponding equality comparers
you provide.
Hence, in our example, if <Label>
is rendered with text="3"
and then, with text={3}
,
we are not going to have an extra re-render.
More documentation is to follow.
Licensed under MIT License.
FAQs
Provides a function to configure React's shouldComponentUpdate() function in a declarative way
The npm package configure-should-component-update receives a total of 2 weekly downloads. As such, configure-should-component-update popularity was classified as not popular.
We found that configure-should-component-update 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
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.