CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-react-addons-shallow-compare

Legacy React addon for performing shallow comparison of props and state to optimize component rendering performance

Overall
score

99%

Overview
Eval results
Files

task.mdevals/scenario-4/

Comparison Utility

A utility function that performs shallow comparison to determine whether two sets of properties have changed.

Capabilities

Compares primitive values correctly

  • Comparing objects with identical primitive values returns false (no changes detected) @test
  • Comparing objects with different primitive values returns true (changes detected) @test

Handles NaN edge cases

  • Comparing objects where both have NaN values in the same property returns false (no changes detected) @test
  • Comparing objects where one has NaN and the other has a number returns true (changes detected) @test

Distinguishes positive and negative zero

  • Comparing objects with +0 and -0 in the same property returns true (changes detected) @test

Handles null and undefined values

  • Comparing objects with null values in the same property returns false (no changes detected) @test
  • Comparing objects with undefined values in the same property returns false (no changes detected) @test
  • Comparing objects where one has null and the other has undefined returns true (changes detected) @test

Implementation

@generates

API

/**
 * Performs shallow comparison between two objects representing current and next properties.
 * Returns true if the objects are different (changes detected).
 * Returns false if the objects are the same (no changes detected).
 *
 * @param {Object} current - The current properties object
 * @param {Object} next - The next properties object
 * @returns {boolean} true if objects differ, false if they are the same
 */
function hasChanged(current, next) {
  // IMPLEMENTATION HERE
}

module.exports = { hasChanged };

Dependencies { .dependencies }

react-addons-shallow-compare { .dependency }

Provides shallow comparison functionality for detecting property changes.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-react-addons-shallow-compare

tile.json