Skip to content

Instantly share code, notes, and snippets.

View jamesplease's full-sized avatar
🍕
yum

James Please jamesplease

🍕
yum
  • USA
View GitHub Profile
```js
function reducer(state, action) {
switch (action): {
// ...handle the different `action.type` values here
}
}
```
The plugin for this reducer would look like this:
{
type: 'REQUEST_PENDING',
crudAction: 'read',
resourceTypes: {
books: {
resources: [{}, {}, {}],
meta: [{}, {}, {}],
lists: {
favorites: [ ... ]
}
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
});
{
type: 'UPDATE_RESOURCES',
resourceTypes: {
books: {
resources: [{}, {}, {}],
meta: [{}, {}, {}],
lists: {
favorites: [ ... ]
}
},
String file contents
String file contents
@jamesplease
jamesplease / file1.txt
Created February 3, 2018 01:25
teatstt
String file contents
String file contents
@jamesplease
jamesplease / 0.provider.jsx
Last active February 1, 2018 00:42
Hello
import ModalContext from './modal-context';
class Parent extends Component {
render() {
return (
<ModalContext.Provider value={this.state.modalContext}>
<Child/>
</ModalContext.Provider>
);
}
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 (