0

With the following code I can check the type of the incoming props, however how do I check the internals of each object inside of the array assets?

AssetsTable.propTypes = {
    assets: PropTypes.array.isRequired
}

Say for example if I wanted to check assets[0].id: PropTypes.string.isRequired

enter image description here

1 Answer 1

4

I think you can do something like

React.PropTypes.arrayOf(
  React.PropTypes.shape({
    id: React.PropTypes.string.isRequired
  })
).isRequired

see here for more information

Sign up to request clarification or add additional context in comments.

1 Comment

Nice! That was it thanks! I didn't see that kinda of nested example in the docs for checking an object in the Array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.