How to specify a constructor with a functional component (fat arrow syntax)?

后端 未结 5 771
南笙
南笙 2020-12-15 16:46

Given this component:

import React from \'react\'
import ReactDOM from \'react-dom\'
import PropTypes from \'prop-types\'

const NewGoalInput = props => {         


        
5条回答
  •  心在旅途
    2020-12-15 17:36

    You don't. The kind of component in your example is called "stateless functional component". It has no state and no lifecycle methods. If you want your component to be stateful you'll have to write it as a class component.

提交回复
热议问题