Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a custom loading #196

Open
OFCL08 opened this issue Jul 31, 2021 · 0 comments
Open

Add a custom loading #196

OFCL08 opened this issue Jul 31, 2021 · 0 comments

Comments

@OFCL08
Copy link

OFCL08 commented Jul 31, 2021

I suggest adding a prop for a custom loading, just like errorComponent. Or adding an "on load" function to know when the file has finished loading.

e.g. file-viewer.jsx
Add these

FileViewer.propTypes = {
  errorComponent: PropTypes.element,
  filePath: PropTypes.string.isRequired,
  fileType: PropTypes.string.isRequired,
  loadingComponent: PropTypes.element,
  onError: PropTypes.func,
  unsupportedComponent: PropTypes.element,
};

FileViewer.defaultProps = {
  errorComponent: null,
  loadingComponent: null,
  onError: () => null,
  unsupportedComponent: null,
};

e.g. loading.jsx
Could look like this

import React from 'react';

import 'styles/loading.scss';

const Loading = () => (
  <div className="loading-container">
    {props.loadingComponent
      ? <props.loadingComponent {...props} />
      : <span className="loading" />}
  </div>
);

export default Loading;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant