import React from 'react'
import Loadable from 'react-loadable'

const DefaultLoadingScreen = ({ isLoading, error }) => {
  // Handle the loading state
  if (isLoading) {
    return <div>Loading...</div>
  } else if (error) {
    return <div>Sorry, there was a problem loading the page.</div>
  } else {
    return null
  }
}

export const registerFeature = (loader) => (
  Loadable({
    loader,
    loading: DefaultLoadingScreen,
  })
)