小编09f*_*its的帖子

ReactJS - Pass multiple functions to child components as a single prop

I am passing multiple function={this.function} as singular props from the parent component to its child components. I don't get any errors or issues with this, but I'm wondering if there's a better / cleaner way to code it.

To illustrate, here is a sample code (the parent component):

import React, { Component } from 'react';

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

   function2 = () => {
      // Does something
   }; …
Run Code Online (Sandbox Code Playgroud)

javascript parent-child prop reactjs

3
推荐指数
1
解决办法
5717
查看次数

标签 统计

javascript ×1

parent-child ×1

prop ×1

reactjs ×1