Comments (4)
Will do, sorry I haven't tried the fix sooner and thanks so much for your work looking into it and fixing it with the little info I gave! Just been busy with another part of the project but I'll try it this week hopefully 😄
from react-redux-loading-bar.
Just wanted to let you know I tested this on our production build (locally) and it seems to have worked perfectly. Thanks so much for tracking this down and the quick fix! 😄
from react-redux-loading-bar.
@tofumatt Thanks for the bug report, it was a tricky one!
The problem can be reproduced with Server Side Rendering and strict Content Security Policy for styles (i.e. style-src
doesn't have 'unsafe-inline'
).
Some context:
I intentionally haven't introduced any dependencies or CSS files into the loading bar to keep it lightweight and easy to configure. It can be used without any preprocessors.
When the browser loads an SSR page, it blocks inline styles on its elements. Once Loading Bar kicks in, it alters its inline styles to emulate progress. Turned out that style attributes that were initially blocked will not be applied to the element unless they change.
Inline styles in 2.8.2:
var style = {
width: this.state.percent + '%',
transition: 'width ' + ANIMATION_TIME + 'ms linear',
opacity: '1'
}
if (this.shouldShow()) {
style.opacity = '1';
} else {
style.opacity = '0';
}
width
and opacity
are dynamic attributes. The transition
attribute will never be applied to the element as it was initially blocked by CSP and never changes. However, the animation will be shown because width
and opacity
combined with custom CSS class for color, height, and positioning is enough to make it work.
Inline styles in 2.9.0:
var style = {
opacity: '1',
transform: 'scaleX(' + this.state.percent / 100 + ')',
transformOrigin: 'left',
transition: 'transform ' + ANIMATION_TIME + 'ms linear',
width: '100%',
willChange: 'transform, opacity'
}
if (this.shouldShow()) {
style.opacity = '1';
} else {
style.opacity = '0';
}
Static styles as transformOrigin
, transition
, width
, willChange
will be ignored.
That change in animation mechanics in 2.9.0 revealed the problem.
Please give v2.9.1
a try.
It renders a placeholder on the server side and replaces it with the actual Loading Bar with proper styles after mount. That should not trigger CSP warnings on initial page render and fix the animation.
from react-redux-loading-bar.
@tofumatt I'm going to close this issue as I think it is resolved in v2.9.1.
Feel free to reopen if the fix didn't work for you.
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
- [Question] Does this support the [email protected]? HOT 4
- 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.