Ciao, я получил ваш код из репозитория github, а затем, чтобы проверить его, я использовал response-native-expo-gitpod . Это просто пустой проект, который можно запустить на gitpod. Затем я вставил ваш код из репозитория github в приложение js и запустил его. Я сделал логин в HomeScreen
:
![enter image description here](https://i.stack.imgur.com/MEFrc.jpg)
Then I filled Details
info and password fields:
![enter image description here](https://i.stack.imgur.com/q43y7.jpg)
Then I clicked Add Password
button. And the result was that button_click
function is called just one time!
This is DetailsScreen
code:
function DetailsScreen({ navigation, route }) {
const [text3, setText3] = useState("");
const [text4, setText4] = useState("");
const { param1, param2 } = route.params;
const button_click = () => {
console.log("button_click");
add_password(text3, text4, param1, param2);
};
return (
setText3(text3)}
defaultValue={text3}
/>
setText4(text4)}
defaultValue={text4}
/>
Exactly like yours (except the log to check how many times function is called).
The log I received is:
введите описание изображения здесь
calling add_password
- это еще один журнал, который я вставил в функцию add_password
.
Кажется, все работает хорошо!
Примечание: это мой package.json
:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start -c --host tunnel",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject",
"test": "jest --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/samples": "~3.0.3",
"@expo/vector-icons": "^10.0.3",
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/native": "^5.7.3",
"@react-navigation/stack": "^5.9.0",
"@react-navigation/web": "^1.0.0-alpha.9",
"expo": "^35.0.0",
"expo-asset": "^7.0.0",
"expo-constants": "^7.0.0",
"expo-font": "^7.0.0",
"expo-web-browser": "^7.0.0",
"firebase": "^7.17.2",
"react": "16.8.3",
"react-dom": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
"react-native-gesture-handler": "~1.3.0",
"react-native-safe-area-context": "^0.3.6",
"react-native-screens": "^2.10.1",
"react-native-web": "^0.11.7",
"react-navigation": "^3.12.0"
},
"devDependencies": {
"babel-preset-expo": "^7.0.0",
"jest-expo": "^35.0.0"
},
"private": true
}