React class versus functional components and dash


So I finally decided to take the plunge and learn javascript and React, in large part because I wanted to understand and use dash better. Now in the book I am learning, they are showing everything with functional react components, hooks etc and suggest that class component are outdated, going so far to suggest they may be deprecated in the future. When I look at the dash examples on how to write javascript components for dash - it seems to be all using class components.

I would be thankful if someone could explain more how functional and class components are different from dash and how I would use functional components inside dash.

Thank you

Hi @hhoeflin

These are great questions. There are no plans to remove classes from React- see:

We intend for Hooks to cover all existing use cases for classes, but we will keep supporting class components for the foreseeable future. At Facebook, we have tens of thousands of components written as classes, and we have absolutely no plans to rewrite them. Instead, we are starting to use Hooks in the new code side by side with classes.

See this post for more information on both using classes and functional components in Dash:

1 Like