question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setState causes flicker in chrome

See original GitHub issue

Environment

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});
  }
`;

screen shot 2018-11-13 at 4 32 11 pm

Demo: https://drive.google.com/file/d/1LVwv1OpvHA7viQc4LafPJWv9TslT5eee/view

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

27reactions
jitenderchand1commented, Nov 14, 2018

to fixed this issue for now I have moved my font import to css file.


@font-face {
  font-family: 'Muli';
  src: url('../fonts/Muli/Muli-Regular.ttf');
}

@font-face {
  font-family: 'MuliBold';
  src: url('../fonts/Muli/Muli-Bold.ttf');
}

app.js

import './styles/main.scss';

1reaction
oriSomethingcommented, Nov 14, 2018

@jimthedev I had the same problem with flickering when using @font-face with createGlobalStyle

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found