-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix blank screen when exiting the Onfido page in IOU flow #6461
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit wary of this change (as always with platform checking). Did you ever get to the bottom of what was causing the crash? I read the issue and this Slack thread, and didn't see a resolution per se. Would you be willing to explain this change a bit more?
I share your concerns and wish that I had an explanation for why Sorry that's not a great explanation of the solution! |
Hmm, well I don't think this is too egregious, but I'm gonna request another pair of eyes just in case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the fix for the crash, I feel like it's safe enough. If it works, it works 🤷
That said, I don't really want to condone the use of getPlatform()
in this context because, even though it's less code than the alternative, it goes against our style guideline for platform-specific code. Instead, the way we would normally implement this change is using platform-specific file extensions:
- Create a
Base
component, in this case,BaseOnfidoWeb
or something. It would be the same as this, except without thecomponentWillUnmount
- Create lightweight wrappers in
index.website.js
andindex.desktop.js
, and pass a ref to theBaseOnfidoWeb
component. - Implement
componentWillUnmount
inindex.website.js
only.
So the resultant files would look something like this:
index.desktop.js
import BaseOnfidoWeb from './BaseOnfidoWeb';
import onfidoPropTypes from './onfidoPropTypes';
// On desktop, we do not want to teardown onfido, because it causes a crash.
// See https://github.com/Expensify/App/issues/6082
const Onfido = BaseOnfidoWeb;
Onfido.propTypes = onfidoPropTypes;
Onfido.displayName = 'Onfido';
export default Onfido;
index.website.js
import React, {Component} from 'react';
import lodashGet from 'lodash/get';
import BaseOnfidoWeb from './BaseOnfidoWeb';
import onfidoPropTypes from './onfidoPropTypes';
class Onfido extends Component {
constructor(props) {
super(props);
this.baseOnfido = null;
}
componentWillUnmount() {
const onfidoOut = lodashGet(this, 'baseOnfido.onfidoOut');
if (!onfidoOut) {
return;
}
onfidoOut.tearDown();
}
render() {
return (
<BaseOnfidoWeb
ref={e => this.baseOnfido = e}
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
/>
);
}
}
Onfido.propTypes = onfidoPropTypes;
export default Onfido;
Thanks for the detailed explanation @roryabraham! Updated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB: I'm hesitant about calling it BaseOnfido
because it's not used by index.native.js
, like other BaseXYZ
components usually would be. That's why I suggested BaseOnfidoWeb
(because desktop is essentially a subset of web, thanks to Electron.js)
Updated! |
Thanks @roryabraham |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to production by @roryabraham in version: 1.1.18-3 🚀
|
Details
The
onfido.tearDown()
function causes the app to crash on Desktop.Fixed Issues
$ #6082
Tests
Send money > enter amount > next
QA Steps
Same as above.
Tested On
Screenshots
Web
web.mov
Mobile Web
Desktop
desktop.mov
iOS
Android