Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/components/DeeplinkWrapper/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import PropTypes from 'prop-types';
import {PureComponent} from 'react';

const propTypes = {
/** Children to render. */
children: PropTypes.node.isRequired,
};

class DeeplinkWrapper extends PureComponent {
render() {
return this.props.children;
}
function DeeplinkWrapper({children}) {
return children;
}

DeeplinkWrapper.propTypes = propTypes;

export default DeeplinkWrapper;
23 changes: 11 additions & 12 deletions src/components/DeeplinkWrapper/index.website.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import {PureComponent} from 'react';
import {useEffect} from 'react';
import Str from 'expensify-common/lib/str';
import * as Browser from '../../libs/Browser';
import ROUTES from '../../ROUTES';
Expand All @@ -12,9 +12,13 @@ const propTypes = {
children: PropTypes.node.isRequired,
};

class DeeplinkWrapper extends PureComponent {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use memo equivalent to PureComponent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need memo here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought no need at first. But this actually includes entire app views as children.
So still you persist no performance optimization here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also fine no memo usage but let's just guarantee that this won't cause any performance regressions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it shouldn't. I've checked both implementations but I noticed no difference. And memo uses shallow comparison so it won't work for props.children and will always cause a rerender.

componentDidMount() {
if (!this.isMacOSWeb() || CONFIG.ENVIRONMENT === CONST.ENVIRONMENT.DEV) {
function isMacOSWeb() {
return !Browser.isMobile() && typeof navigator === 'object' && typeof navigator.userAgent === 'string' && /Mac/i.test(navigator.userAgent) && !/Electron/i.test(navigator.userAgent);
}

function DeeplinkWrapper({children}) {
useEffect(() => {
if (!isMacOSWeb() || CONFIG.ENVIRONMENT === CONST.ENVIRONMENT.DEV) {
return;
}

Expand All @@ -26,16 +30,11 @@ class DeeplinkWrapper extends PureComponent {
App.beginDeepLinkRedirectAfterTransition();
return;
}
App.beginDeepLinkRedirect();
}

isMacOSWeb() {
return !Browser.isMobile() && typeof navigator === 'object' && typeof navigator.userAgent === 'string' && /Mac/i.test(navigator.userAgent) && !/Electron/i.test(navigator.userAgent);
}
App.beginDeepLinkRedirect();
}, []);

render() {
return this.props.children;
}
return children;
}

DeeplinkWrapper.propTypes = propTypes;
Expand Down