-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Labels
Description
This component is super usefull when fetching data from remote server.
Since such an operation could fail, it would be great to allow the display of a "fallback" component that does not seems to load infinitly, but instead inform the user of the error.
I think it could look like this:
import loader from 'hoc-react-loader'
const Component = ({ users }) => <div>Component {JSON.stringify(users)}</div>
const Fallback = ({ error }) => <div className="error-message">{`Retrieval of users failed with error ${error}`}</div>
export default loader(Component, { wait: ['users'], error: ['error'], fallback: Fallback })And error could also be specify as a function.
Thoughts?
frinyvonnick