setState causes flicker in chrome
See original GitHub issueEnvironment
System:
- OS: Linux 4.14 Amazon Linux 2
- CPU: (2) x64 Intel® Xeon® CPU E5-2686 v4 @ 2.30GHz
- Memory: 368.21 MB / 3.85 GB
- Container: Yes
- Shell: 4.2.46 - /bin/bash
Binaries:
- Node: 8.12.0 - /usr/local/bin/node
- npm: 6.4.1 - /usr/local/bin/npm
npmPackages:
- babel-plugin-styled-components: ^1.8.0 => 1.8.0
- styled-components: ^4.0.2 => 4.0.3
##Bug description:
When I change state of component. fonts are re-requested every time. Main.js
const App = () => (
<Provider store={store}>
<ThemeProvider theme={theme}>
<Fragment>
<Routes />
<GlobalStyle />
<Font />
</Fragment>
</ThemeProvider>
</Provider>
);
export default App;
font.js
import { createGlobalStyle } from 'styled-components';
import Muli from './Muli/Muli-Regular.ttf';
import MuliBold from './Muli/Muli-Bold.ttf';
export default createGlobalStyle`
@font-face {
font-family: 'Muli';
src: url(${Muli});
}
@font-face {
font-family: 'MuliBold';
src: url(${MuliBold});
}
`;
Demo: https://drive.google.com/file/d/1LVwv1OpvHA7viQc4LafPJWv9TslT5eee/view
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to fix image flickering by rerendering once and for all?
At the first stage of the development I've faced with irritating blinking and flickering by rerendering the image. How can avoid it?
Read more >Avoid flickering images when state change? : r/reactjs - Reddit
The state change is causing the images to rerender. There could be any number of reasons, that's what you'll have to discover.
Read more >Google Chrome Flickering? Here's How To Fix It | SoftwareKeep
Flickering in Google Chrome may cause you discomfort with flashing while watching a video, moving your mouse, or hovering over specific website elements....
Read more >How to work with React the right way to avoid some common ...
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application...
Read more >When does React re-render components? - Felix Gerschau
Example of Chrome's Paint Flashing option in action. ... React re-renders a component when you call the setState function to change the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
to fixed this issue for now I have moved my font import to css file.
app.js
import './styles/main.scss';
@jimthedev I had the same problem with flickering when using
@font-face
withcreateGlobalStyle