react error handling in functional component