Home / Function/ getAttributes() — react Function Reference

getAttributes() — react Function Reference

Architecture documentation for the getAttributes() function in App.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  af493b9a_23a7_2ac8_0705_a73027025095["getAttributes()"]
  7796199a_976b_30de_2bf9_e72aa702c083["App"]
  af493b9a_23a7_2ac8_0705_a73027025095 -->|defined in| 7796199a_976b_30de_2bf9_e72aa702c083
  beb7074a_2384_4b98_8fdf_82ff0b15b5c5["componentWillUpdate()"]
  beb7074a_2384_4b98_8fdf_82ff0b15b5c5 -->|calls| af493b9a_23a7_2ac8_0705_a73027025095
  style af493b9a_23a7_2ac8_0705_a73027025095 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fixtures/attribute-behavior/src/App.js lines 884–931

  getAttributes(table, rowPatternHashes, sortOrder, filter, completedHashes) {
    // Filter
    let filteredAttributes;
    switch (filter) {
      case ALL:
        filteredAttributes = attributes.filter(() => true);
        break;
      case COMPLETE:
        filteredAttributes = attributes.filter(attribute => {
          const row = table.get(attribute);
          return completedHashes.has(row.rowPatternHash);
        });
        break;
      case INCOMPLETE:
        filteredAttributes = attributes.filter(attribute => {
          const row = table.get(attribute);
          return !completedHashes.has(row.rowPatternHash);
        });
        break;
      default:
        throw new Error('Switch statement should be exhaustive');
    }

    // Sort
    switch (sortOrder) {
      case ALPHABETICAL:
        return filteredAttributes.sort((attr1, attr2) =>
          attr1.name.toLowerCase() < attr2.name.toLowerCase() ? -1 : 1
        );
      case REV_ALPHABETICAL:
        return filteredAttributes.sort((attr1, attr2) =>
          attr1.name.toLowerCase() < attr2.name.toLowerCase() ? 1 : -1
        );
      case GROUPED_BY_ROW_PATTERN: {
        return filteredAttributes.sort((attr1, attr2) => {
          const row1 = table.get(attr1);
          const row2 = table.get(attr2);
          const patternGroup1 = rowPatternHashes.get(row1.rowPatternHash);
          const patternGroupSize1 = (patternGroup1 && patternGroup1.size) || 0;
          const patternGroup2 = rowPatternHashes.get(row2.rowPatternHash);
          const patternGroupSize2 = (patternGroup2 && patternGroup2.size) || 0;
          return patternGroupSize2 - patternGroupSize1;
        });
      }
      default:
        throw new Error('Switch statement should be exhaustive');
    }
  }

Domain

Subdomains

Frequently Asked Questions

What does getAttributes() do?
getAttributes() is a function in the react codebase, defined in fixtures/attribute-behavior/src/App.js.
Where is getAttributes() defined?
getAttributes() is defined in fixtures/attribute-behavior/src/App.js at line 884.
What calls getAttributes()?
getAttributes() is called by 1 function(s): componentWillUpdate.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free