File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -173,15 +173,15 @@ store
173173// I can also dispatch a thunk async action from a component
174174// any time its props change to load the missing data.
175175
176- import React from ' react' ;
176+ import React from ' react'
177177import { connect } from ' react-redux'
178178
179179function SandwichShop (props ) {
180- const { dispatch , forPerson } = props;
180+ const { dispatch , forPerson } = props
181181
182182 useEffect (() => {
183- dispatch (makeASandwichWithSecretSauce (forPerson));
184- }, [forPerson]);
183+ dispatch (makeASandwichWithSecretSauce (forPerson))
184+ }, [forPerson])
185185
186186 return < p> {this .props .sandwiches .join (' mustard' )}< / p>
187187}
Original file line number Diff line number Diff line change @@ -70,7 +70,10 @@ function TodoListContainer(props) {
7070 // We create bound versions of these functions now so we can
7171 // pass them down to our child later.
7272
73- const boundActionCreators = useMemo (() => bindActionCreators (TodoActionCreators, dispatch), [dispatch]);
73+ const boundActionCreators = useMemo (
74+ () => bindActionCreators (TodoActionCreators, dispatch),
75+ [dispatch]
76+ )
7477 console .log (boundActionCreators)
7578 // {
7679 // addTodo: Function,
@@ -87,7 +90,7 @@ function TodoListContainer(props) {
8790 // This will work:
8891 let action = TodoActionCreators .addTodo (' Use Redux' )
8992 dispatch (action)
90- }, []);
93+ }, [])
9194
9295 return < TodoList todos= {todos} {... this .boundActionCreators } / >
9396
You can’t perform that action at this time.
0 commit comments