简体   繁体   English

导出 function 内部的 function ReactJs

[英]Export function that inside a function ReactJs

Iam trying to call a function that inside a function but when I write export for the function it show me error我试图在 function 内部调用 function 但是当我为 function 编写导出时它显示错误

 const ProfileContent = () => { const { instance, accounts } = useMsal(); const [graphData, setGraphData] = useState(null); const [graphDatah, setGraphDatah] = useState(null); function RequestProfileData() { // Silently acquires an access token which is then attached to a request for MS Graph data instance.acquireTokenSilent({...loginRequest, account: accounts[0] }).then((response) => { callMsGraph(response.accessToken).then(response => setGraphData(response)); }); } //-------------------------- function takesheet() { return ( // Silently acquires an access token which is then attached to a request for MS Graph data instance.acquireTokenSilent({ account: accounts[0] }).then((response) => { PostData(response.accessToken).then(response => setGraphDatah(response)); }) ); }

Iam trying to export takesheet function but Iam getting this error, I want to call takesheet in another file.我正在尝试导出记录表 function 但我收到此错误,我想在另一个文件中调用记录表。 在此处输入图像描述

I hope this code will help you.我希望这段代码对你有帮助。 We have to return a value when we use function.当我们使用 function 时,我们必须返回一个值。

  const a=()=>{
    function b(){
        console.log("HELLO")
    }
    return b
   }
let test=a();
test()

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

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