Get started with react-fast-compare CDN
MIT licensed
Library: React FastCompare. Optimizes rendering by comparing props, state, re-renders changed components.
Tags:- fast
- equal
- react
- compare
- shouldComponentUpdate
- deep-equal
Stable version
Copied!
How to start using react-fast-compare CDN
import React from 'react';
import FastShallowComparator from 'react-fast-compare';
function MyComponent(props) {
const [state, setState] = React.useState({ count: 0 });
const handleClick = () => {
setState((prevState) => ({ count: prevState.count + 1 }));
};
return (
<div>
<button onClick={handleClick}>Increment</button>
<p>Count: {FastShallowComparator(state, { count: state.count + 1 }).isEqual() ? 'Same' : 'Different'}</p>
</div>
);
}
export default MyComponent;
Copied!
Copied!
Copied!