Как передать функцию?
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Settings" component={Settings} />
Хочу из home передать в settings функцию и установить в ней новые значения
Home
export default function HomeScreen() {
const [taskList, setTaskList] = useState<Array<Item>>([]);
const navigation = useNavigation();
const goToMessageScreen = () => {
navigation.navigate('Settings', {
setTaskList,
});
};
}
<Button title="Submit" onPress={goToMessageScreen} color="green" />
Settings
const Settings = () => {
const route = useRoute();
const taskClear = () => {
route.params.setTaskList("")
}
return (
<View style={styles.container}>
<Text style={styles.title}>
<Button title="Submit" onPress={taskClear} color="green"/>
</Text>
</View>
);
};
Срабатывает но выдаёт предупреждение
his can break usage such as persisting and restoring state. This might happen if you passed non-serializable values such as function, class instances etc. in params. If you need to use components with callbacks in your options, you