#Wrong import? Need help!

45 messages · Page 1 of 1 (latest)

north thorn
#

Hey guys,
Im trying to code a function for my BeReal Clone App where you open the camera thing to take a picture. I imported the necessary imports and builds but why is this keep getting red?
App is crashing cause of this.
Thx to everyone who could help peepoLove

lapis junco
#

what are the errors?

north thorn
#

one sec

lapis junco
#

CameraType is a type, not a value

#

it's "front" | "back"

#

you'd use those strings literally

#

it's not an enum

north thorn
north thorn
lapis junco
#

when you do useState(null), ts doesn't know if you want other types as well, it's just a state typed null
you have to specify what type it should have

#

useRef as well

#

useState("back") would have a similar problem, so for that, use useState<CameraType>("back")

north thorn
#

well yeah that does make more sense

#

And here?

lapis junco
#

well, what's the error

north thorn
#

let me rerun for a sec

lapis junco
#

looks like a type error, so this won't show up in your app

#

just hover over the error

north thorn
#

"Camera can not be used as a JSX Componet"

#

And that confuses me too?

lapis junco
#

i don't even see Camera in docs

#

docs are showing it should be CameraView

north thorn
#

am i tripping AquaCrazyCry

lapis junco
#

are you even referencing the docs

#

what version of expo-camera are you using?

north thorn
lapis junco
#

ah. hm. not the right version to check.

#

what version of expo are you using

#

also, use npm ls expo rather than what's shown in package.json, please

north thorn
lapis junco
#

what docs were you referencing before?

north thorn
#

genereally google haha

#

Does this make sense to you now?

lapis junco
#

you still haven't typed useRef

north thorn
#

or wha

lapis junco
#

no clue tbh

#

but definitely not that

north thorn
#

Nah is just realised my code was bad, so im rewriting it like in the docs

north thorn
#

@lapis junco
Do you know why this Exit Func is not working?

<TouchableOpacity 
            style={[styles.button, styles.exitButton]} 
            onPress={onExit}
          >
#

no error, just nothing is happening

#

got it