We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1409585 commit ecce49bCopy full SHA for ecce49b
client/src/components/Categories/CategoryList.js
@@ -24,6 +24,7 @@ export class CategoryList extends Component {
24
/>
25
</div>,
26
)}
27
+ {resourceList.empty && resourceList.loading && <p>Loading...</p>}
28
<CategoryForm
29
isNew={true}
30
form="category-new"
client/src/components/Dashboard.js
@@ -23,6 +23,7 @@ export class Dashobard extends Component {
23
return (
<div>
<h4>Latest posts</h4>
+ {postsList.empty && postsList.loading && <p>Loading...</p>}
{postsList.data.map(post =>
<div key={post.id}>
<Link to={`/posts/${post.id}`}>{post.title}</Link>
client/src/components/Posts/PostList.js
@@ -75,6 +75,7 @@ export class PostList extends Component {
75
</tbody>
76
</Table>
77
<Pagination {...this.props}></Pagination>
78
79
</div>
80
);
81
}
client/src/components/Users/UserList.js
@@ -43,6 +43,7 @@ export class UserList extends Component {
43
44
45
46
47
48
49
client/src/store/api/reducer.js
@@ -48,12 +48,18 @@ export default (state = initialState, action) => {
case actionType(GET_ONE, SUCCESS): {
return addNormalized(newState, payload);
50
51
+ case actionType(GET_LIST, STARTED): {
52
+ console.log('loading');
53
+ return imm.set(newState, [key, list, 'loading'], true);
54
+ }
55
case actionType(GET_LIST, SUCCESS): {
56
+ console.log('loaded');
57
newState = addNormalized(newState, payload);
58
newState = imm.set(newState, [key, list, 'ids'], map(payload.data, 'id'));
59
newState = imm.set(newState, [key, list, 'params'], payload.params);
60
newState = imm.set(newState, [key, list, 'links'], payload.links);
61
newState = imm.set(newState, [key, list, 'meta'], payload.meta);
62
+ newState = imm.set(newState, [key, list, 'loading'], false);
63
return newState;
64
65
case actionType(GET_MANY, SUCCESS): {
client/src/store/api/selectors.js
@@ -19,7 +19,7 @@ export const getMany = (state, resourceName, ids) => {
19
export const getList = (state, resourceName, listName = 'list') => {
20
const byId = get(state, ['api', resourceName, 'byId']) || {};
21
const list = get(state, ['api', resourceName, listName]) || {};
22
- return isEmpty(list)
- ? { data: [], ids: [], links: {}, params: { page: {}, filter: {} } }
- : { ...list, data: list.ids.map(id => byId[id]) };
+ return isEmpty(list.ids)
+ ? { data: [], ids: [], links: {}, params: { page: {}, filter: {} }, loading: true, empty: true }
+ : { ...list, empty: false, data: list.ids.map(id => byId[id]) };
};
client/webpack.config.js
@@ -51,6 +51,11 @@ module.exports = removeEmpty({
'/**': {
target: 'http://localhost:3001',
},
+ // '/**': {
+ // target: 'https://rails-json-api-react.herokuapp.com',
+ // secure: true,
+ // changeOrigin: true,
+ // },
}),
0 commit comments