简体   繁体   English

如何在本机反应中调用另一个 function 内部的 function

[英]how to call a function that is inside another function in react native

I am trying to call a function that is inside another function and I need it to be called by another external function我正在尝试调用另一个 function 内部的 function 并且我需要另一个外部 function 调用它

I needed to call the funcSon function by the callSon function in the same way that it is in my code, I just can't put the necessary code to call it我需要通过 callSon function 以与我的代码中相同的方式调用 funcSon function,我只是无法放置必要的代码来调用它

My Code我的代码

export function callSon() { 
   //...space to call the funcSon function
}

export function funcDaddy() {
   function funcSon() {
       console.log('Hello');
   }
   return <View></View>;
}

You can move the state and funcSon() logic to a redux store.您可以将 state 和funcSon()逻辑移动到 redux 存储区。 In that way they will become globally accessible.通过这种方式,它们将成为全球可访问的。 redux and redux-thunk must be the ways to go https://react-redux.js.org/ . reduxredux-thunk必须是 go https://react-redux.js.org/的方式。 Or you create a custom hook to handle that specific part https://reactjs.org/docs/hooks-custom.html and reuse it whereever needed.或者您创建一个自定义钩子来处理该特定部分https://reactjs.org/docs/hooks-custom.html并在需要时重复使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM