React Naitve Vision Camera Styling Not Working

92 Views Asked by At

I am trying to style react-native-vision-camera Camera component

<Camera
                            ref={selfieRef}
                            style={{
                                position: 'absolute',
                                width: 300,
                                height: 300,
                                left: (width - 300) / 2,
                                top: (height - 300) / 3
                            }}
                            isActive={true}
                            device={devices.front}
                            orientation='portrait'
                            photo={true}
                            enableHighQualityPhotos
                            enablePortraitEffectsMatteDelivery
/>

above code work on android, but on ios it only work when fast refresh. if I hard refresh position goes back to left: 0 right: 0 enter image description here enter image description here

I have tried with styling on Component loaded

 useEffect(() => {
        if (selfieRef?.current) {
            console.log(selfieRef.current.props)
            selfieRef.current.props.style = {
                top: (Dimensions.get('window').height - 350) / 3,
                left: (Dimensions.get('window').width - 300) / 2,
                position: 'absolute',
                width: 300,
                height: 300,
                borderRadius: 5
            }
            console.log(selfieRef.current.props)
        }
    }, [selfieRef])

But it also not working.

0

There are 0 best solutions below