What should be react default prop type for PropTypes.shape?

Tanvi Jaywant

Say I have the following condition:

    static propTypes = {
        deployment: PropTypes.shape({
            getMetrics: PropTypes.func.isRequired,
            getRootMetric: PropTypes.func.isRequired
       }).isRequired,
}

How would I declare the default for deployment ? Would it be undefined or would it be [] ?

Code-Apprentice

Since the prop is required, I see no reason to define a default. Defaults are only useful for optional props which also have a reasonable default value, such as an empty list [] or an empty object {}.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What is the default value of React.PropTypes.func

REACT: What I should write in propTypes when in form I use input type="file'?

React PropTypes import class. Prop type is invalid

Failed prop type: Chat: prop type `room` is invalid; it must be a function, usually from React.PropTypes

Warning: Failed prop type: Game: prop type `game` is invalid; it must be a function, usually from React.PropTypes

ESLint React PropTypes, 'prop' is missing in prop validation

React propTypes: objectOf vs shape?

React Prop Types - On false prop type, reset to default?

Creating custom PropTypes that extend default PropTypes in react

React PropTypes File type

What is the importance of PropTypes in React?

What should the default power be in power.prop.test?

What is the problem with the propTypes object, string and array which makes eslint to have this rule: react/forbid-prop-types?

React PropTypes : Allow different types of PropTypes for one prop

PropTypes isRequired on React Router 4 params prop

What prop type should I check for requiring the source?

React-Typescript: How do I type a default prop?

React PropTypes checks for the wrong type

What type should I use for default arguments that depend on a type parameter?

ReactJs: What should the PropTypes be for this.props.children?

What TypeScript type should React children be set to?

What should be the type of the state using react and typescript?

What is the Typescript type to accept any kind of React Component as prop?

_react2.default.PropTypes.function is undefined

TypeError: _react2.default.PropTypes is undefined

What exactly is a "Prop" in React?

Can I infer TypeScript type from a PropTypes shape?

RN - ProgressBarAndroid: manually calling React.PropTypes for the `indeterminate` prop

Is it possible to "loosely" define an object using React.PropTypes.shape?