Uploaded image for project: 'stripes-smart-components'
  1. stripes-smart-components
  2. STSMACOM-107

Refactor away lifecycle hooks deprecated in React 17

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed (View Workflow)
    • Priority: P3
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Template:

      Description

      The following components throw lint errors because they use the deprecated React lifecycle hook, componentWillUpdate.

      componentWillUpdate is deprecated since React 16.3.0, use UNSAFE_componentWillUpdate instead, see https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate

      lib/ProxyManager/ProxyManager.js
      lib/SearchAndSort/SearchAndSort.js
      
      ✖ 2 problems (2 errors, 0 warnings)
      

      To not use the UNSAFE method, we need to use getDerivedStateFromProps or componentDidUpdate. The former occurs before render, but is a static method, meaning it cannot access `this` (instance props). The latter occurs after render() and cannot update the state (which would cause flickering); it is often used to apply focus() to an element.

        TestRail: Results

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                Unassigned Unassigned
                Reporter:
                rjruizes Roman Ruiz-Esparza
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    TestRail: Runs

                      TestRail: Cases