Skip to main content

ImageCropPickerButton

Content

Image crop picker button which provides a dialog to user to photo selection or image taking or removing existing one and also showing the result to user.

If image is not selected it will show a button with icon.

Uses PhotoTakingButton as button component.

Uses react-native-image-crop-picker for image picking.

Params

NameTypeRequiredDefault valueDescription
onImagePicked(image: CropperImage) => voidTrue-On image picked callback
onRemoveImage() => voidTrue-On remove image callback
onPickerError(error: Error) => voidFalseUndefinedCallback with error when something went wrong
imageImageURISource or nullFalseUndefinedSelected image which will be shown and used
iconImageURISourceFalseImageResources.cameraIcon which will be shown when image is not present and over the selected image
styleViewStyleFalseUndefinedStyle of button
iconStyleImageStyleFalseUndefinedStyle of icon
imageStyleImageStyleFalseUndefinedStyle of image
disabledbooleanFalseUndefinedIs button disabled

Usage example

    const [photo, setPhoto] = useState<ImageURISource | null>(null);

const onRemoveImage = useCallback(() => {
setPhoto(null);
}, [setPhoto]);

const onImagePicked = useCallback(
(nextImage) => {
setPhoto({uri: nextImage.path});
},
[setPhoto],
);

return (
<ImageCropPickerButton
image={photo}
onRemoveImage={onRemoveImage}
onImagePicked={onImagePicked}
onPickerError={console.error}
/>
);