I have 2 nested screens in the navigator
and I wish to use a function from one of those screens to another (from Screen1.js
to Screen2.js
). The function I want to call in Screen2.js
is addList()
. This is the Screen1.js
export default function Screen1({navigation}){
//...
function addList (list){
//Code...
};
//...
}
I have tried to import the function addList
and use it like this in Screen2
:
import addList from './Screen1
//...
export default function Screen2({navigation}){
//...
function createSomething(){
//...
addList(list);
//...
}
//...
}
However, my attempt was unsuccessful. How can I perform to do this?