Created
August 2, 2017 20:18
-
-
Save mariusandra/a76dbb1a4d3a7a117a56cfcf5d720ad3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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