Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React-Router-Native passing image as parameter

$
0
0

Im trying to pass image as my parameter on react-router-native and trying to get the data from the location.state but im having issue.

I usually do this to display image

Import Icon from '../image/icon.png';<View><Image source={icon} /></View>

but i want to pass the icon to different page

Page1

import Icon from '../image/icon.png';const nav = useNavigate();const onClick = () => {    nav('Page2/:icon', {state: {icon: Icon}})}<> <touchableOpacitiy onpress={onClick} /></>

Page2

let param = useLocation();</><Image source={param.state}></>

I receive the value in param.state but im having error when i set it on the image source because its unknown type. is there a best way to pass image parameter on the other page in react-router-native? im also using typescript on my pages.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>