Reactjs convert class components to functional components

前端 未结 3 1587
渐次进展
渐次进展 2020-12-22 05:47

I am new in react. I want to use form stepper in my project. I found one library but in that library using class components. I am little confuse convert class components to

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-22 06:33

    Functional components do not use state like a class. You can use the useState method with a functional component though. But to answer your question.

      class MyClassComponent extends Component {
         render() {
          return(
           // code
        )
       }      
     }
        export default MyClassComponent;
    

    Here is a functional component

    function MyFunctionalComponent() {
        return(
        //code
      )
    }
    export default MyFunctionalComponent;
    

提交回复
热议问题