Doesn't work with new function based React.useState approach
goodwill opened this issue · comments
I think due to the lifecycle design of the component, somehow this doesn't work with the const [stateName,changeStateFunction]=React.useState(default) approach, the state just not changeable even I call the change state function. Please consider refactor.
Hi @goodwill not sure what exact functionality you may be referring to but at least the example code can be converted into functional component.
Sample code for everyone
// @ts-ignore
import { ImageManipulator } from 'expo-image-crop'
import React, { useState } from 'react';
export default function Crop() {
const [isVisible, setisVisible] = useState(true);
const [ uri, setUri] = useState('https://i.pinimg.com/originals/39/42/a1/3942a180299d5b9587c2aa8e09d91ecf.jpg')
function onToggleModal(photo) {
setisVisible(true),
setisVisible(false),
}
return (
<ImageManipulator
photo={{ uri }}
isVisible={isVisible}
onPictureChoosed={({ uri: uriM }) => setUri(uriM)}
onToggleModal = {() => {onToggleModal(uri)}}
/>
)
};
Cheers
UPDATE: The code was updated in Oct 2020 so may have been refactored since.