Legacy React addon for performing shallow comparison of props and state to optimize component rendering performance
Overall
score
99%
Build a utility that performs shallow equality comparison of two property objects using Object.is() semantics for value comparison.
Your task is to implement a function arePropsEqual(prevProps, nextProps) that compares two property objects and returns true if they are equal, false otherwise.
The function must use Object.is() semantics when comparing property values, which means:
@generates
/**
* Compares two property objects for equality.
* Returns true if properties are equal (using Object.is() semantics for values),
* false otherwise.
*
* @param {Object} prevProps - The previous properties object
* @param {Object} nextProps - The next properties object
* @returns {boolean} True if properties are equal, false otherwise
*/
function arePropsEqual(prevProps, nextProps) {
// IMPLEMENTATION HERE
}
module.exports = { arePropsEqual };prevProps = {a: 1, b: "hello"} and nextProps = {a: 1, b: "hello"}, the function returns true @testprevProps = {a: 1, b: "hello"} and nextProps = {a: 2, b: "hello"}, the function returns false @testprevProps = {value: NaN} and nextProps = {value: NaN}, the function returns true @testprevProps = {value: +0} and nextProps = {value: -0}, the function returns false @testprevProps = {obj: {x: 1}} and nextProps = {obj: {x: 1}} (different object instances), the function returns false @testobj = {x: 1}, prevProps = {obj: obj} and nextProps = {obj: obj} (same reference), the function returns true @testprevProps = {a: 1, b: 2} and nextProps = {a: 1}, the function returns false @testprevProps = {value: null} and nextProps = {value: undefined}, the function returns false @testProvides Object.is()-based shallow equality comparison functionality for React components.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-react-addons-shallow-comparedocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10