react-firebase
react-firebase copied to clipboard
Handle errors?
There is currently no way of capturing errors from database reads, for example if permission is denied. We could add a handler to https://github.com/unfold/react-firebase/blob/master/src/connect.js#L106
subscriptionRef.on('value', update, onError)
But how to map that value to props? We could just map the value to the same prop key, which would require an additional check props[key] instanceof Error, or we could extend the mergeProps function to also pass and error argument that the user could map to props as they desire, something like (we could attach the key to the error for convenience):
const mergeProps = (ownProps, firebaseProps, error) => ({
error: 'There was an error reading ' + error.key + ' Firebase said: ' + error.message
})
@gmaclennan I've taken a stab a this in https://github.com/unfold/react-firebase/tree/merge-props-error-handling if you'd like to give it a try. There's no docs yet but the added tests should be understandable enough.
Are you still tracking this @gmaclennan or should we go ahead without your input?