Skip to content

Instantly share code, notes, and snippets.

@mariusandra
Created August 2, 2017 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariusandra/a76dbb1a4d3a7a117a56cfcf5d720ad3 to your computer and use it in GitHub Desktop.
Save mariusandra/a76dbb1a4d3a7a117a56cfcf5d720ad3 to your computer and use it in GitHub Desktop.
import './styles.scss'
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { kea } from 'kea'
const books = {
1: 'book1',
2: 'book2'
}
const booksLogic = kea({
reducers: ({ actions }) => ({
books: [books, PropTypes.object, {}]
})
})
@kea({
selectors: ({ selectors }) => ({
book: [
() => [booksLogic.selectors.books, (_, props) => props.bookId],
(books, bookId) => books[bookId],
PropTypes.object
]
})
})
class BookDetail extends Component {
render () {
const { book } = this.props
return <div>{book}</div>
}
}
export default class Playground extends Component {
render () {
return (
<div className='playground-scene'>
<BookDetail bookId={1} />
<BookDetail bookId={2} />
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment