I'm using expo-router and need to pass some params back. How to do that?
I use router push here:
<TouchableOpacity style={styles.qrButton} onPress={()=> {router.push(`/rent-bike/qr-scanner`)}}>
<Text style={styles.qrText}>Użyj kodu QR</Text>
</TouchableOpacity>
Then I scan QR code and want to pass it back to display on same page:
const handleBarCodeScanned = ({type, data}) => {
setScanData(true)
console.log(`data: ${data}`);
console.log(`type: ${type}`);
router.back()
};
I can't see any solutions.
Go back then update the route parameters.
router.back()
router.setParams({ foo: "bar" })
How about using router.replace instead of goBack(). That way you can add params: router.replace({pathname: 'some-path', params: {param: qrData }}).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With