Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loading spinner while requesting data in backend #336

Open
SujalLama opened this issue Jul 18, 2021 · 1 comment · May be fixed by #420
Open

loading spinner while requesting data in backend #336

SujalLama opened this issue Jul 18, 2021 · 1 comment · May be fixed by #420
Assignees

Comments

@SujalLama
Copy link
Contributor

No description provided.

@lmmrssa lmmrssa assigned rjpadilla and unassigned rjpadilla Jul 22, 2021
@lmmrssa
Copy link
Member

lmmrssa commented Jul 22, 2021

One simple place to start with

If you click on library menu or go to url http://github.planetfarms.io:3000/library
On page load of library it trigger action to fetch library resources

if (!search) dispatch(listResources('', pageNumber))

Which will call action
export const listResources = ({ sort, pageNumber }) => async (dispatch) => {

Action which fetch the resources of library and will intiate state of loading by reducer
dispatch({ type: RESOURCE_LIST_REQUEST })

After data returned will call reducer
dispatch({ type: RESOURCE_LIST_SUCCESS, payload: data })

All these reducers are under
export const resourceListReducer = (state = { resources: [] }, action) => {

payload returned by reducers in action will be grabbed under
const resourceList = useSelector((state) => state.listResources)

Here we can get loading and use that value somewhere inside
<DashboardLayout title='Library'>

To display or hide loading icon
For loader you can use some package like
https://www.npmjs.com/package/react-loader-spinner

@ABee-Tech ABee-Tech linked a pull request Aug 3, 2021 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants