Skip to content

Flash of unstyled content (FOUC) #110

Open
@thomasjm

Description

@thomasjm

Summary

The react-filepond component has a flash of unstyled content for me when it first comes up. This happens when I'm using React server-side rendering. It's happened for me when using both Gatsby.js and Next.js.

Here's a recording of me refreshing the page to show it:

filepond

How to reproduce

Just use the Filepond component in a SSR-ed app. I'm using it exactly like the example in this repo does. Here's a simplified version of my component:

import * as React from "react";

import "filepond/dist/filepond.min.css";
import { FilePond } from "react-filepond";

export default class MyComponent extends React.PureComponent {

  render() {
    return (
      <div>
          <FilePond allowMultiple={false}
                    onprocessfile={this.onProcessFile}
                    onprocessfilestart={this.onProcessFileStart}
                    beforeAddFile={this.beforeAddFile}
                    server={{
                      process: {
                        url: "/api/scratchpad/from_file",
                        method: "POST",
                        withCredentials: true,
                        headers: {},
                        onload: this.onLoad,
                        onerror: this.onError,
                        ondata: this.onData
                      }
                    }} />
      </div>
    );
  }
}

Expected behaviour

It should have the styled loaded before rendering the component so that there isn't a flicker.

Additional information

Environment Version
OS Linux
Device Laptop
Browser Chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions