
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
react-immutable-render-mixin
Advanced tools
React PureRenderMixin replacement for immutable-js library
This library exposes 4 distinct options for immutable rendering:
React.createClass
supportReact.Component
shouldComponentUpdate
implementationsThis library when used as a mixin/decorator replaces the PureRenderMixin when using facebook/immutable-js library with React
This Mixin and HoC implements shouldComponentUpdate
method using prop and state equality with Immutable.is().
We also expose the shallowEqualImmutable
to allow developers to craft a custom shouldComponentUpdate
method as needed.
npm i react-immutable-render-mixin
import immutableRenderMixin from 'react-immutable-render-mixin';
React.createClass({
mixins: [immutableRenderMixin],
render: function() {
return <div className={this.props.className}>foo</div>;
}
});
import React from 'react';
import { immutableRenderDecorator } from 'react-immutable-render-mixin';
class Test extends React.Component {
render() {
return <div></div>;
}
}
export default immutableRenderDecorator(Test);
import React from 'react';
import { immutableRenderDecorator } from 'react-immutable-render-mixin';
@immutableRenderDecorator
class Test extends React.Component {
render() {
return <div></div>;
}
}
shouldComponentUpdate
import React from 'react';
import { shouldComponentUpdate } from 'react-immutable-render-mixin';
class Test extends React.Component {
constructor(props) {
super(props);
this.shouldComponentUpdate = shouldComponentUpdate.bind(this);
}
render() {
return <div></div>;
}
}
shouldComponentUpdate
import React from 'react';
import { shallowEqualImmutable } from 'react-immutable-render-mixin';
class Test extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
return !shallowEqualImmutable(this.props, nextProps) || !shallowEqualImmutable(this.state, nextState);
}
render() {
return <div></div>;
}
}
Exports:
var immutableRenderMixin = require('react-immutable-render-mixin').default;
var immutableRenderDecorator = require('react-immutable-render-mixin').immutableRenderDecorator;
var shallowEqualImmutable = require('react-immutable-render-mixin').shallowEqualImmutable;
var shouldComponentUpdate = require('react-immutable-render-mixin').shouldComponentUpdate;
Full Example:
var immutableRenderMixin = require('react-immutable-render-mixin').default;
React.createClass({
mixins: [immutableRenderMixin],
render: function() {
return <div className={this.props.className}>foo</div>;
}
});
FAQs
React PureRenderMixin replacement for immutable-js library
We found that react-immutable-render-mixin 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.