Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-100896

Add common hooks to frontend-js-react-web

    Details

      Description

      There are some hooks that are so basic, common, and useful that we probably want to provide them in frontend-js-react-web. Some initial candidates I am thinking of:

      • usePrevious (substitute for componentDidUpdate)
      • useMounted (useful in async callbacks, so that you can check whether you are still mounted before firing off a set-state call)
      • useEventListener (encapsulates common pattern of adding an event listener on mount and removing it on unmount)

      I think we'll want to keep this list small and conservative to prevent it from becoming an infinite grab bag of hooks, but there are definitely some hooks (like the ones above) that should be pretty uncontroversial (I wouldn't be surprised if some, like usePrevious, make it into React itself at some point).

        Attachments

          Activity

            People

            • Assignee:
              brian.chan Brian Chan
              Reporter:
              greg.hurrell Greg Hurrell
              Recent user:
              Enterprise Release HU
              Participants of an Issue:
              Engineering Assignee:
              Greg Hurrell
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Packages

                Version Package
                7.2.10 DXP FP2
                7.2.10.1 DXP SP1
                7.2.X
                Master