Skip to content

Instantly share code, notes, and snippets.

@bradfordlemley
Last active May 29, 2019 23:14
Show Gist options
  • Save bradfordlemley/5a200a6ac410b3cd035297cef94d28c9 to your computer and use it in GitHub Desktop.
Save bradfordlemley/5a200a6ac410b3cd035297cef94d28c9 to your computer and use it in GitHub Desktop.
React component with methods in composed state
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