faceyspacey / react-universal-component

🚀 The final answer to a React Universal Component: simultaneous SSR + Code Splitting
MIT License
1.7k stars 80 forks source link

How to remove "Loading..." in react-universal-component? #196

Closed swham-ai closed 4 years ago

swham-ai commented 5 years ago

Currently I am using react-universal-component with code-splitting...

Everytime I switch page it shortly displays "Loading..." like 0.1 second then render the proper page.

I just want to delete "Loading..." so that there is no blinking while switching any page. How can I do that with react-universal-component? is there any example?

cdoublev commented 5 years ago

You can override the default component shown with a component that returns null.

  const loadingFn = ({ page }) => import(`./${page}`)
  const loadingOptions = {
    loading: () => null,
}
const UniversalComponent = universal(loadingFn, loadingOptions)

Alternatively, you can use loadingTransition: true (see README).

swham-ai commented 4 years ago

Thank you very much it helped

const loadingOptions = {
  loading: () => null,
  loadingTransition: false
}

const UniversalComponent = universal(props => import(`./${props.page}`), loadingOptions)