Last active
May 29, 2019 23:14
-
-
Save bradfordlemley/5a200a6ac410b3cd035297cef94d28c9 to your computer and use it in GitHub Desktop.
React component with methods in composed state
This file contains hidden or 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 { connect } from '@stated-library/react'; | |
import { appState$ } from './state'; | |
const App = ({addTodo, allTodos, visibleTodos}) => | |
<> | |
<button onClick={() => addTodo("New todo")}> | |
Add Todo | |
</button> | |
<div>All todos: {allTodos.map(todo => <div>{todo.title}</div>)}</div> | |
<div>Visible todos: {visibleTodos.map(todo => <div>{todo.title}</div>)}</div> | |
</> | |
export default connect(appState$)(App); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment