Comments (24)
@ashwinimnnit Could you provide more info about your setup? Do you dispatch _FULFILLED
or _REJECTED
actions at the end of async events?
from react-redux-loading-bar.
yes I have dispatched _FULFILLEd or _REJECTED action, the loadingBarReducer
is executing and in case HIDE
i'm getting newstate = 1. actually on page load there are several ajax call executing
from react-redux-loading-bar.
@ashwinimnnit Please make sure the you call _FULFILLED
or _REJECTED
the same amount of times as _PENDING
. Basically speaking, the Loading Bar will be shown until all ajax request complete.
If you want to forcefully hide Loading Bar, you can call resetLoading()
at any time.
from react-redux-loading-bar.
I tried resetLoading()
but it is throwing error Uncaught (in promise) TypeError: (0 , _reactReduxLoadingBar.resetLoading) is not a function
from react-redux-loading-bar.
Please show me the code you're using.
from react-redux-loading-bar.
import { showLoading, hideLoading, resetLoading } from 'react-redux-loading-bar';
export default function loadingBarMiddleware(config = {}) {
return (store) => next => (action) => {
console.log('dispatch', action);
const isPending = new RegExp(`_FETCHING_`, 'g')
const isFulfilled = new RegExp(`_FETCHED_`, 'g')
const isRejected = new RegExp(`_FETCH_.*_FAILED`, 'g')
if (action.type.match(isPending)) {
store.dispatch(showLoading())
} else if (action.type.match(isFulfilled) ||
action.type.match(isRejected)) {
store.dispatch(hideLoading())
//store.dispatch(resetLoading())
}
return next(action);
}}
from here I'm dispatching the actions..
from react-redux-loading-bar.
@ashwinimnnit Well, apparently I forgot to export resetLoading
action. I just published the v2.6.5, please give it a try.
from react-redux-loading-bar.
ok :)
from react-redux-loading-bar.
Yeah that error has gone... but still hideLoading is not hiding the loading bar
from react-redux-loading-bar.
Could you check what is in the store?
from react-redux-loading-bar.
@mironov : but show and hide action are executing same number of time...
I debug it ... in the end I'm getting newState = 1 when case is Hide
in loadingBarReducer()
from react-redux-loading-bar.
@mironov i checked store and get loadingBar: 2
from react-redux-loading-bar.
resetLoading
explicitly sets the counter to 0.
If the counter is > 0 that might mean that showLoading
has been called after resetLoading
.
Could you check the order of actions that were dispatched using redux logger middleware?
from react-redux-loading-bar.
Yeah sequence is somethig like this.
loading-bar/SHOW ---> loading-bar/HIDE ---> loading-bar/SHOW ---> loading-bar/HIDE and at last newState is 1
from react-redux-loading-bar.
In that case the counter should be 0. Please make sure there're no more loading bar related actions dispatched.
from react-redux-loading-bar.
when the first time showLoading() is called loadingBar: 2
in store , I think it should be 1
from react-redux-loading-bar.
Yes it should be 1. Please check your initial state of the store when the app is being loaded.
from react-redux-loading-bar.
initially the state is 0 ---> then it become 1 ---> then loading-bar/SHOW
action executes which makes it 2.
from react-redux-loading-bar.
When you say "then it become 1" — what do you mean? What action makes the counter to become 1?
from react-redux-loading-bar.
@ashwinimnnit Something is changing the counter to 1 before showLoading
kicks in. I can take a look deeper if you can push related code to a repo or gist.
from react-redux-loading-bar.
@ashwinimnnit Do you use the bundled loadingBarReducer
or a custom one? It looks like the loadingBarReducer
returns 1 on store initialization.
from react-redux-loading-bar.
from react-redux-loading-bar.
@mironov :
Here at store initialization arguments[0] contains 1 when the action type is @@redux/PROBE_UNKNOWN_ACTION_9.o.0.b.b.5.1.k.b.6.7.k.q.0.8.u.x.r
function loadingBarReducer() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var newState = void 0;
switch (action.type) {
case SHOW:
newState = state + 1;
break;
case HIDE:
newState = state > 0 ? state - 1 : 0;
break;
case RESET:
newState = 0;
break;
default:
return state;
}
return newState;
}
from react-redux-loading-bar.
@ashwinimnnit Could you show your combineReducers
function?
from react-redux-loading-bar.
Related Issues (20)
- Minified react error 321 HOT 1
- Can't get loading bar to stay within parent container HOT 2
- Loading bar is not displayed? HOT 6
- Financing HOT 2
- When array data in response have more than one item - hiding is skipping in production HOT 1
- Update peerDependencies to include React 18 HOT 1
- CreateSlice Redux HOT 1
- Error: Element type is invalid HOT 1
- TypeError: connect is not a function after upgrading to react-redux 9.1.1 HOT 1
- How to use with react-router HOT 2
- It does not render any classname nor interact with the store HOT 2
- Step Progress HOT 1
- RTL Support HOT 1
- Usage without redux HOT 3
- Highlight updates shows up a blinking loading bar. HOT 2
- Facing following issue while using 'react-redux-loading-bar' HOT 1
- `resetLoading()` method is not fully resetting the component. HOT 3
- Loading bar not working with redux-persist HOT 3
- × Could not find "store" in the context of "Connect(LoadingBar)". HOT 3
- Use for polling HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-redux-loading-bar.