title: Passing down multiple methods within single prop React.js
body: <p>I have a react.js component where I want to pass down a bunch of different methods to child components from the parent component, the methods modify the state of the parent component.</p>
  
  <pre><code>class Page extends Component {
    constructor(props) {
      super(props);
  
      this.state = {
        items: this.props.items,
        currentItemID: 1
      };
  
      this.actions = this.actions.bind(this);
    }
  
    render() {
      return (
        &lt;div className="page"&gt;
          {
            this.state.items.map(item =&gt;
              &lt;Item key={item._id} item={item} actions={this.actions} /&gt;
            )
          }
        &lt;/div&gt;
      );
    }
  
    actions() {
      return {
        insertItem: function (itemID) {
          const currentItems = this.state.items;
          const itemPosition = this.state.items.map((item) =&gt; item._id).indexOf(itemID);
  
          const blankItem = {
            _id: (new Date().getTime()),
            content: ''
          };
  
          currentItems.splice(itemPosition + 1, 0, blankItem)
  
          this.setState({
            items: currentItems,
            lastAddedItemID: blankItem._id
          });
        },
        setCurrentItem: function (itemID) {
          this.setState({ currentItemID: itemID });
        },
        focus: function(itemID) {
          return (itemID === this.state.currentItemID);
        }
      }
    }
  </code></pre>
  
  <p>In my child component, I am trying to use the focus method in the componentDidMount lifecyle method as shown below:</p>
  
  <pre><code> componentDidMount() {
      if (this.props.actions().focus(this.props.item._id)) {
        this.nameInput.focus();
      }
    }
  </code></pre>
  
  <p>However, I am getting the error </p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'currentItemID' of undefined</p>
  </blockquote>
  
  <p>in the definition of the focus method, within the actions methods. Can anyone point me in the right direction as to why I'm getting the error or an alternative way to pass down multiple actions to child components?</p>