JavaScript for WordPress Forums Gutenberg Development Best Practice: Class Components or functional component with HOCs?

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #126717
    Claybeast
    Participant

    Best Practice: Class Components or functional component with HOCs?

    I am having trouble figuring out if I should be favoring using Class Components or functional components. A small case is when we want to get external API data. We can pull ‘component’ from wp.element and extend our object with the react component class. We can then use lifecycle hooks to fetch the api data. An alternative is we can wrap a simple functional component in a HOC such as ‘withSelect’ and use ‘getEntityRecords’

    Is there a best practice? Not just for this particular instance but should we be trying to avoid using react extend and work with Gutenburg’s functions?

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.