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(React): Update support react 19 #516

Merged
merged 1 commit into from
Jan 8, 2025
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
2 changes: 1 addition & 1 deletion example/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import Geosuggest from '../../src/Geosuggest';

const App = (): JSX.Element => {
const App = (): React.JSX.Element => {
/**
* When the input receives focus
*/
Expand Down
114 changes: 69 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"url": "https://github.com/ubilabs/react-geosuggest/issues"
},
"peerDependencies": {
"react": "^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
"react": "^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
"react-dom": "^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
},
"dependencies": {
"classnames": "^2.3.2",
Expand All @@ -34,8 +34,8 @@
"@types/jsdom": "^21.1.1",
"@types/lodash.debounce": "^4.0.7",
"@types/mocha": "^10.0.1",
"@types/react": "^18.2.18",
"@types/react-dom": "^18.2.7",
"@types/react": "19.0.2",
"@types/react-dom": "19.0.2",
"@types/sinon": "^10.0.16",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
Expand Down
6 changes: 4 additions & 2 deletions src/Geosuggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -604,15 +604,17 @@ export default class GeoSuggest extends React.Component<Props, State> {
/**
* Render the view
*/
render(): JSX.Element {
render(): React.JSX.Element {
const attributes = filterInputAttributes(this.props);
const classes = classnames('geosuggest', this.props.className, {
'geosuggest--loading': this.state.isLoading
});
const input = (
<Input
className={this.props.inputClassName}
ref={(i): Input | null => (this.input = i)}
ref={(i: Input | null) => {
this.input = i;
}}
value={this.state.userInput}
doNotSubmitOnEnter={!this.state.isSuggestsHidden}
ignoreTab={this.props.ignoreTab}
Expand Down
6 changes: 4 additions & 2 deletions src/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default class Input extends React.PureComponent<Props, unknown> {
/**
* Render the view
*/
render(): JSX.Element {
render(): React.JSX.Element {
const attributes = filterInputAttributes(this.props);
const classes = classnames('geosuggest__input', this.props.className);
const shouldRenderLabel = this.props.label && this.props.id;
Expand All @@ -174,7 +174,9 @@ export default class Input extends React.PureComponent<Props, unknown> {
<input
className={classes}
id={`geosuggest__input${this.props.id ? `--${this.props.id}` : ''}`}
ref={(i): HTMLInputElement | null => (this.input = i)}
ref={(i: HTMLInputElement | null) => {
this.input = i;
}}
type={this.props.inputType}
{...attributes}
value={this.props.value}
Expand Down
15 changes: 10 additions & 5 deletions src/suggest-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface Props {
readonly renderSuggestItem?: (
suggest: Suggest,
userInput: string
) => JSX.Element | string;
) => React.JSX.Element | string;
readonly onMouseDown: (event: React.MouseEvent) => void;
readonly onMouseOut: (event: React.MouseEvent) => void;
}
Expand Down Expand Up @@ -50,7 +50,10 @@ export default class SuggestItem extends React.PureComponent<Props, unknown> {
/**
* Replace matched text with the same in bold
*/
formatMatchedText(userInput: string, suggest: Suggest): JSX.Element | string {
formatMatchedText(
userInput: string,
suggest: Suggest
): React.JSX.Element | string {
if (!userInput || !suggest.matchedSubstrings) {
return suggest.label;
}
Expand Down Expand Up @@ -127,7 +130,7 @@ export default class SuggestItem extends React.PureComponent<Props, unknown> {
/**
* Render the view
*/
render(): JSX.Element {
render(): React.JSX.Element {
const {suggest} = this.props;
const classes = classnames(
'geosuggest__item',
Expand All @@ -140,7 +143,7 @@ export default class SuggestItem extends React.PureComponent<Props, unknown> {
: null
}
);
let content: JSX.Element | string = suggest.label;
let content: React.JSX.Element | string = suggest.label;

if (this.props.renderSuggestItem) {
content = this.props.renderSuggestItem(suggest, this.props.userInput);
Expand All @@ -151,7 +154,9 @@ export default class SuggestItem extends React.PureComponent<Props, unknown> {
return (
<li
className={classes}
ref={(li): HTMLLIElement | null => (this.ref = li)}
ref={(li: HTMLLIElement | null) => {
this.ref = li;
}}
style={this.props.style}
onMouseDown={this.props.onMouseDown}
onMouseOut={this.props.onMouseOut}
Expand Down
4 changes: 2 additions & 2 deletions src/suggest-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface Props {
readonly renderSuggestItem?: (
suggest: Suggest,
userInput: string
) => JSX.Element | string;
) => React.JSX.Element | string;
readonly onSuggestSelect: (suggest: Suggest) => void;
readonly onSuggestMouseDown: (event: React.MouseEvent) => void;
readonly onSuggestMouseOut: (event: React.MouseEvent) => void;
Expand Down Expand Up @@ -56,7 +56,7 @@ export default class SuggestList extends React.PureComponent<Props, unknown> {
* Render the view
* @return {Function} The React element to render
*/
render(): JSX.Element {
render(): React.JSX.Element {
const classes = classnames(
'geosuggest__suggests',
this.props.suggestsClassName,
Expand Down
2 changes: 1 addition & 1 deletion src/types/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface Props {
readonly getSuggestLabel?: (
suggest: google.maps.places.AutocompletePrediction
) => string;
readonly renderSuggestItem?: (suggest: Suggest) => string | JSX.Element;
readonly renderSuggestItem?: (suggest: Suggest) => string | React.JSX.Element;
readonly autoActivateFirstSuggest?: boolean;
readonly style?: {
input?: any;
Expand Down