1

Gutenberg has MediaUpload component that allows selecting images from media library (its docs).

It allows to pass button to a render property, for example:

<MediaUpload
  onSelect={ ( media ) => console.log( 'selected ' + media.length ) }
  allowedTypes={ ALLOWED_MEDIA_TYPES }
  value={ mediaId }
  render={ ( { open } ) => (
    <Button onClick={ open }>
      Open Media Library
    </Button>
  ) }
/>

But I also have another component (outside of the render function), doubleclick on it should open the same media library.

<AnotherComponent 
  ondoubleclick={ /* how do I open the same media modal here? */ }
></AnotherComponent>

Is there some way to do it with a single <MediaUpload/> component, or I need multiple?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.