Skip to content
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

[Chore] Remove default props and react-onclickoutside in react functional components #2679

Merged
merged 10 commits into from
Oct 10, 2024

Conversation

heshan0131
Copy link
Contributor

@heshan0131 heshan0131 commented Oct 8, 2024

Use of defaultProps and findDomNode has been deprecated. This change tries to remove use of both, to avoid React warnings in the dev console

Screenshot 2024-10-08 at 2 00 43 PM Screenshot 2024-10-08 at 2 05 14 PM
  • Remove defaultProps in functional components, some class components are still using defaultProps
  • Add default props to functional components method to be used
  • Fix replace-component example
  • Remove use of react-clickoutside (which uses findDomNode)

Still seeing warnings about deprecated APIs from the following dependencies, further dependency upgrade is needed

  • react-modal uses findDomNode
  • react-markdown uses defaultProps
  • react-router: uses childContextTypes

Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Copy link

netlify bot commented Oct 8, 2024

Deploy Preview for keplergl2 ready!

Name Link
🔨 Latest commit 066785c
🔍 Latest deploy log https://app.netlify.com/sites/keplergl2/deploys/6706eb56361d160008c66311
😎 Deploy Preview https://deploy-preview-2679--keplergl2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
@heshan0131 heshan0131 changed the title [Chore] Remove default props in react functional components [Chore] Remove default props and react-onclickoutside in react functional components Oct 8, 2024
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
Signed-off-by: Shan He <heshan0131@gmail.com>
@heshan0131 heshan0131 requested a review from igorDykhta October 8, 2024 21:58
Signed-off-by: Shan He <heshan0131@gmail.com>
@@ -59,7 +59,7 @@ const config = {
// automatically injected kepler.gl package version into the bundle
replace({
__PACKAGE_VERSION__: KeplerPackage.version,
exclude: /node_modules/
include: /constants\/src\/default-settings\.ts/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this will fix the child_process not found error from loaders.gl

@@ -0,0 +1,32 @@
// Copyright 2022 Foursquare Labs, Inc. All Rights Reserved.

import document from 'global/document';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove react-onclickoutside, implements a simple hooks to handle click outside

Copy link
Collaborator

@igorDykhta igorDykhta left a comment

Choose a reason for hiding this comment

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

Looks good. I hope it won't introduce too many conflicts for our upstreaming.

}
]
};
LoadDataModal.defaultLoadingMethods = [
Copy link
Collaborator

@igorDykhta igorDykhta Oct 9, 2024

Choose a reason for hiding this comment

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

Do we need to duplicate loading methods? defaultLoadingMethods is same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We still need this so that the custom LoadDataModal can access this via LoadDataModal.defaultLoadingMethods

https://github.com/keplergl/kepler.gl/pull/2679/files#r1794197038

But we don't need ti duplicated declaration in 2 places

...component,
component: SIDEBAR_COMPONENTS[component.id],
iconComponent: SIDEBAR_ICONS[component.id]
}));

const getCustomPanelProps = get(CustomPanels, ['defaultProps', 'getProps']) || (() => ({}));
const fullPanels = [...defaultSidePanels, ...(CustomPanels.panels || [])];
Copy link
Collaborator

@igorDykhta igorDykhta Oct 9, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we are accessing Sidepanel.defaultProps.panels in studio, now the property can be accessed at SidePanel.defaultPanels


export default withTheme(onClickOutside(CustomPicker) as React.ComponentType<CustomPickerProps>);
export default withTheme(CustomPicker as React.FC<CustomPickerProps>);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need to cast here.

@heshan0131
Copy link
Contributor Author

Looks good. I hope it won't introduce too many conflicts for our upstreaming.

Not that much, most of them can be fixed by following the type errors

@@ -11,7 +11,7 @@ import {loadRemoteMap, loadSample, loadSampleConfigurations} from '../actions';

const CustomLoadDataModalFactory = (...deps) => {
const LoadDataModal = LoadDataModalFactory(...deps);
const defaultLoadingMethods = LoadDataModal.defaultProps.loadingMethods;
const defaultLoadingMethods = LoadDataModal.defaultLoadingMethods;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here we can access the default loading methods

Signed-off-by: Shan He <heshan0131@gmail.com>
@heshan0131 heshan0131 merged commit 5764b06 into master Oct 10, 2024
12 checks passed
@heshan0131 heshan0131 deleted the remove-default-props branch October 10, 2024 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants