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
```js | |
function reducer(state, action) { | |
switch (action): { | |
// ...handle the different `action.type` values here | |
} | |
} | |
``` | |
The plugin for this reducer would look like this: |
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
{ | |
type: 'REQUEST_PENDING', | |
crudAction: 'read', | |
resourceTypes: { | |
books: { | |
resources: [{}, {}, {}], | |
meta: [{}, {}, {}], | |
lists: { | |
favorites: [ ... ] | |
} |
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
fetch('https://jsonplaceholder.typicode.com/posts/1') | |
.then(res => { | |
const text = res.text(); | |
console.log(res.bodyUsed); | |
// => true | |
var newResponse = new Response(res.body, res); | |
console.log(newResponse.bodyUsed); | |
// => `true` if using Chrome, `false` if using Safari, Firefox, or node-fetch | |
}); |
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
{ | |
type: 'UPDATE_RESOURCES', | |
resourceTypes: { | |
books: { | |
resources: [{}, {}, {}], | |
meta: [{}, {}, {}], | |
lists: { | |
favorites: [ ... ] | |
} | |
}, |
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
String file contents |
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
String file contents |
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
String file contents |
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
String file contents |
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 ModalContext from './modal-context'; | |
class Parent extends Component { | |
render() { | |
return ( | |
<ModalContext.Provider value={this.state.modalContext}> | |
<Child/> | |
</ModalContext.Provider> | |
); | |
} |
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 React, { Component } from 'react'; | |
import { connect } from 'react-redux'; | |
import { bindActionCreators } from 'redux'; | |
import { readBook } from '../redux/books/action-creators'; | |
class App extends Component { | |
render() { | |
const { isFetchingBook, book } = this.props; | |
return ( |