In this lesson we convert the class-based CurrencyCodePicker
component to a function component. To do so we employ the following strategy:
class
keyword to function
and remove the extends React.Component
partrender()
method in the function bodythis.
to reference methods or variablesconnect()
as-is (for now)After applying this technique we can see that we've successfully converted the CurrencyCodePicker from a class-based React component to a function component and the application should continue working as it did before.
This lesson does not use (or even reference hooks) and is meant to demonstrate the simplest case of migrating from a class
to a function
component. It's also interesting to note that connect()
continues to work fine on function components. We didn't need to touch any of the redux code.