3
I’m using the React (16.11.0
) with Proptypes (15.7.2
) and Hooks.
And I have a component that receives an object with some data from the database. Testing the data using the console.log
:
{ console.log('Carousel reciving: ', typeof informations, informations) }
Print the following message:
Carousel reciving: object (12) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
Data is sent to the component by calling:
<Carousel informations={informations} isLoading={isLoading} />
Component:
const Carousel = ({ informations, isLoading }) => (
<ReactPlaceholder ...algumas props />...algum contúdo</ReactPlaceholder>
) // Carousel
But it doesn’t matter if I change the Proptype to vector or object, it keeps giving the following error:
Warning: Failed prop type: Invalid prop
informations
of typearray
supplied toCarousel
, expectedobject
.
If I change to PropType.object.isRequired
, the error says that the given value is of type array. What if I change to PropType.array.isRequired
, the error says that the given value is of the object type:
Carousel.propTypes = {
informations: PropTypes.object.isRequired,
isLoading: PropTypes.bool.isRequired,
} // propTypes
I know I could use the function of fetch
within the component, but this data is shared with other components.