Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

ReactElement doesn't work in propTypes #53

Open
fatso83 opened this issue Apr 1, 2019 · 0 comments
Open

ReactElement doesn't work in propTypes #53

fatso83 opened this issue Apr 1, 2019 · 0 comments

Comments

@fatso83
Copy link
Contributor

fatso83 commented Apr 1, 2019

I had this propTypes declaration:

ImageGallery.propTypes = propTypes(
  {
    classes: t.Object,
    className: t.maybe(t.String), // applied to root object
    width: t.maybe(t.String), // from withWidth() - needed for breakpoints
    images: t.list(GalleryImage),
    actionIconType: t.Function, // this is a React Element
    onSelect: t.maybe(t.Function),
    onPictureClick: t.maybe(t.Function),
    children: t.maybe(t.list(t.Object))
  },
  {strict: true}
);

which is used like this:

<ImageGallery 
    actionIconType={RemoveButton} 
    images={this.mapImagesToGalleryImages(includedImages, [])}
    onSelect={this.removeSelectedImage}/>

The actionIconType prop is a React Element, but it never matches. We had to convert it to t.Function for it to accept functional components.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant