PropTypes in functional stateless component

前端 未结 5 661
情深已故
情深已故 2020-12-24 04:01

Without using class, how do I use PropTypes in functional stateless component of react?

export const Header = (props) => (
   
hi
)
5条回答
  •  庸人自扰
    2020-12-24 04:48

    It's done the same way you do with Class Based Components

    import PropTypes from "prop-types";
    
        const = function_name => {}
    
        function_name.propTypes = {
           prop_name : PropTypes.number
           . . . . . . . . . . . . . .
        }
    

    Hope This Helps !

提交回复
热议问题