This documentation is for the old Kea 0.28. To see the latest docs, click here!

connect(options)

Shorthand for kea({ connect: options })

Usage

import React, { Component } from 'react'
import { connect } from 'kea'

import menuLogic from '../menu/logic'
import dynamicLogic from '../dynamic/logic'

@connect({
  actions: [
    menuLogic, [
      'openMenu',
      'closeMenu'
    ]
  ],
  props: [
    menuLogic, [
      'isOpen as isMenuOpen'
    ],
    dynamicLogic.withKey(props => props.id), [
      'dynamicProp as thatProp'
    ]
  ]

})
export default class MyComponent extends Component {
  render () {
    const { isMenuOpen, thatProp } = this.props
    const { openMenu, closeMenu } = this.actions

    return (
      <div>
        {thatProp}
        <button onClick={isMenuOpen ? closeMenu : openMenu}>Toggle menu</button>
      </div>
    )
  }
}