Javascript ReactJS-将多个函数作为单个道具传递给子组件

Javascript ReactJS-将多个函数作为单个道具传递给子组件,javascript,reactjs,parent-child,prop,Javascript,Reactjs,Parent Child,Prop,我将多个function={this.function}作为单数道具从父组件传递到其子组件。我没有发现任何错误或问题,但我想知道是否有更好/更干净的编码方法 下面是一个示例代码(父组件): import React,{Component}来自'React'; 导出默认类应用程序扩展组件{ 函数1=()=>{ //做点什么 }; 函数2=()=>{ //做点什么 }; 函数3=()=>{ //做点什么 }; 函数4=()=>{ //做点什么 }; 函数5=()=>{ //做点什么 }; rende

我将多个
function={this.function}
作为单数道具从父组件传递到其子组件。我没有发现任何错误或问题,但我想知道是否有更好/更干净的编码方法

下面是一个示例代码(父组件):

import React,{Component}来自'React';
导出默认类应用程序扩展组件{
函数1=()=>{
//做点什么
};
函数2=()=>{
//做点什么
};
函数3=()=>{
//做点什么
};
函数4=()=>{
//做点什么
};
函数5=()=>{
//做点什么
};
render(){
返回(
父组件
);
}
}
这实际上只是代码变得有点长的问题。我想知道是否有一个短的方法来传递函数1到5,也许在一行中


提前谢谢

当然,至少有两种选择:

import React,{Component}来自'React';
导出默认类应用程序扩展组件{
函数={
功能1:()=>{
//做点什么
},
函数2:()=>{
//做点什么
},
功能3:()=>{
//做点什么
},
功能4:()=>{
//做点什么
},
函数5:()=>{
//做点什么
}
}
render(){
返回(
父组件
或
);
}
}

当然,至少有两种选择:

import React,{Component}来自'React';
导出默认类应用程序扩展组件{
函数={
功能1:()=>{
//做点什么
},
函数2:()=>{
//做点什么
},
功能3:()=>{
//做点什么
},
功能4:()=>{
//做点什么
},
函数5:()=>{
//做点什么
}
}
render(){
返回(
父组件
或
);
}
}

你能解释一下函数工作吗?你能解释一下函数工作吗?这正是我想要的,非常感谢!(也感谢你提供了不止一个答案)这正是我想要的,非常感谢!(也因为提供了不止一个答案而受到赞誉)
import React, { Component } from 'react';

export default class App extends Component {
   function1 = () => {
      // Does something
   };

   function2 = () => {
      // Does something
   };

   function3 = () => {
      // Does something
   };

   function4 = () => {
      // Does something
   };

   function5 = () => {
      // Does something
   };

   render() {
      return (
         <div>
            Parent Component
            
            <ChildComponent 
               function1={this.function1}
               function2={this.function2}
               function3={this.function3}
               function4={this.function4}
               function5={this.function5} />
         </div>
      );
   }
}