nanana
nanana

Reputation: 77

How to declare PropsType in this case?

How to declare PropsType in this case?


    import React from 'react'
    import PropsTypes from 'PropsTypes' 

    export default App => {
      return class AppRedux extends React.Component {
        constructor(){
         .....
         props.aaaa
        }
        render() {
          return <App >
        }
      }
    }

Is this possible to PropsType for this case?

Any solution?

Upvotes: 1

Views: 61

Answers (1)

mindmaster
mindmaster

Reputation: 1888

I think that you can declare propTypes this way. Doing it inside of your class component. You have an error in this line:

import PropsTypes from 'PropsTypes'

It should be:

import PropTypes from 'prop-types';

import React from 'react'
import PropTypes from 'prop-types'; 

export default App => {
  return class AppRedux extends React.Component {

    static propTypes = {
       aaaa: PropTypes.string.isRequired
    }

    constructor(){
     .....
     props.aaaa
    }

    render() {
      return <App >
    }
  }
}

Upvotes: 1

Related Questions