mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
Merge branch 'master' into day2-7
This commit is contained in:
@@ -16,7 +16,7 @@ That's right, Redux doesn't just work with React. It can also be used with Vue.j
|
||||
|
||||
The store doesn't magically get passed to the views. It has to be supplied by a `react-redux` component called [`<Provider>`](https://react-redux.js.org/api/provider). A `<Provider>` can be placed anywhere, but it's best to just make it available at the root the app:
|
||||
|
||||
```tsx
|
||||
```js
|
||||
const store = createStore(reducers);
|
||||
|
||||
const App = () => {
|
||||
@@ -32,7 +32,7 @@ const App = () => {
|
||||
|
||||
`react-redux` provides a [`connect()`](https://react-redux.js.org/api/connect) function that turns the Redux store and dispatch functions into props for React components. The state and action dispatchers are passed along with a `<Provider>` component.
|
||||
|
||||
```ts
|
||||
```js
|
||||
const OldComponent = props => {
|
||||
return <div>{props.foo}</div>;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,8 @@ interface TodoFooterProps {
|
||||
}
|
||||
|
||||
const TodoFooter = (props: TodoFooterProps) => {
|
||||
const itemCount = Object.keys(props.todos).filter(id => !props.todos[id].completed).length;
|
||||
const { todos } = props;
|
||||
const itemCount = todos ? Object.keys(todos).filter(id => !props.todos[id].completed).length : 0;
|
||||
|
||||
return (
|
||||
<Stack horizontal horizontalAlign="space-between">
|
||||
|
||||
Reference in New Issue
Block a user