Skip to content

Commit 2a127de

Browse files
committed
feat: apply react18 code transforms
* Applies update-react-imports codemod * Applies pure-component codemod * Migrates ReactDOM.render to createRoot API
1 parent a7d2480 commit 2a127de

43 files changed

Lines changed: 138 additions & 154 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/demos/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* under the terms of the MIT License; see LICENSE file for more details.
77
*/
88

9-
import React, { Component } from "react";
9+
import { Component } from "react";
1010
import { Button, Container, Divider, Header, Menu, Segment } from "semantic-ui-react";
1111
import { CERNVideosReactSearchKit } from "./cern-videos";
1212
import NamespacedExample from "./cern-videos-namespaced/app";

src/demos/cern-videos-namespaced/Results.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import PropTypes from "prop-types";
10-
import React, { Component } from "react";
10+
import { Component } from "react";
1111
import { Grid } from "semantic-ui-react";
1212
import {
1313
ActiveFilters,

src/demos/cern-videos-namespaced/app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable react/display-name */
22
/* eslint-disable react/prop-types */
33
import _truncate from "lodash/truncate";
4-
import React from "react";
54
import { OverridableContext } from "react-overridable";
65
import { Card, Grid, Image, Item } from "semantic-ui-react";
76
import { CERNVideosReactSearchKit2 } from "./cern-videos-2";

src/demos/cern-videos-namespaced/cern-videos-2/App.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* under the terms of the MIT License; see LICENSE file for more details.
77
*/
88

9-
import React from "react";
109
import { InvenioSearchApi } from "../../../lib/api/contrib/invenio";
1110
import {
1211
EmptyResults,

src/demos/cern-videos-namespaced/cern-videos-3/App.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* under the terms of the MIT License; see LICENSE file for more details.
77
*/
88

9-
import React from "react";
109
import { InvenioSearchApi } from "../../../lib/api/contrib/invenio";
1110
import {
1211
EmptyResults,

src/demos/cern-videos/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import _truncate from "lodash/truncate";
1010
import PropTypes from "prop-types";
11-
import React, { Component } from "react";
11+
import { Component } from "react";
1212
import { OverridableContext } from "react-overridable";
1313
import { Accordion, Card, Container, Grid, Image, Item, Menu } from "semantic-ui-react";
1414
import { InvenioSearchApi } from "../../lib/api/contrib/invenio";

src/demos/cern-videos/Results.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import PropTypes from "prop-types";
10-
import React, { Component } from "react";
10+
import { Component } from "react";
1111
import { Grid } from "semantic-ui-react";
1212
import {
1313
ActiveFilters,

src/demos/opensearch/App.js

Lines changed: 60 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
import _truncate from "lodash/truncate";
10+
import { Component } from "react";
1011
import PropTypes from "prop-types";
11-
import React, { Component } from "react";
1212
import { OverridableContext } from "react-overridable";
1313
import {
1414
Button,
@@ -142,65 +142,63 @@ const overriddenComponents = {
142142
"ResultsGrid.item.opensearch": OpenSearchResultsGridItem,
143143
};
144144

145-
export class App extends Component {
146-
render() {
147-
return (
148-
<OverridableContext.Provider value={overriddenComponents}>
149-
<ReactSearchKit searchApi={searchApi} initialQueryState={initialState}>
150-
<Container>
151-
<Grid>
152-
<Grid.Row>
153-
<Grid.Column width={3} />
154-
<Grid.Column width={10}>
155-
<SearchBar />
156-
</Grid.Column>
157-
<Grid.Column width={3} />
158-
</Grid.Row>
159-
</Grid>
160-
<Grid relaxed style={{ padding: "2em 0" }}>
161-
<Grid.Row columns={2}>
162-
<Grid.Column width={4}>
163-
<RangeFacet
164-
title="Year"
165-
agg={{ aggName: "years" }}
166-
rangeSeparator=".."
167-
defaultRanges={[
168-
{ label: "Last 1 year", type: "years", value: 1 },
169-
{ label: "Last 5 years", type: "years", value: 5 },
170-
{ label: "Last 6 months", type: "months", value: 6 },
171-
]}
172-
enableCustomRange
173-
/>
174-
<BucketAggregation
175-
title="Tags"
176-
agg={{ field: "tags", aggName: "tags_agg" }}
177-
renderValuesContainerElement={customAggValuesContainerCmp}
178-
renderValueElement={customAggValueCmp}
179-
/>
180-
<BucketAggregation
181-
title="Employee Types"
182-
agg={{
183-
field: "employee_type.type",
184-
aggName: "type_agg",
185-
childAgg: {
186-
field: "employee_type.subtype",
187-
aggName: "subtype_agg",
188-
},
189-
}}
190-
/>
191-
</Grid.Column>
192-
<Grid.Column width={12}>
193-
<ResultsLoader>
194-
<EmptyResults />
195-
<Error />
196-
<OnResults />
197-
</ResultsLoader>
198-
</Grid.Column>
199-
</Grid.Row>
200-
</Grid>
201-
</Container>
202-
</ReactSearchKit>
203-
</OverridableContext.Provider>
204-
);
205-
}
145+
export function App() {
146+
return (
147+
<OverridableContext.Provider value={overriddenComponents}>
148+
<ReactSearchKit searchApi={searchApi} initialQueryState={initialState}>
149+
<Container>
150+
<Grid>
151+
<Grid.Row>
152+
<Grid.Column width={3} />
153+
<Grid.Column width={10}>
154+
<SearchBar />
155+
</Grid.Column>
156+
<Grid.Column width={3} />
157+
</Grid.Row>
158+
</Grid>
159+
<Grid relaxed style={{ padding: "2em 0" }}>
160+
<Grid.Row columns={2}>
161+
<Grid.Column width={4}>
162+
<RangeFacet
163+
title="Year"
164+
agg={{ aggName: "years" }}
165+
rangeSeparator=".."
166+
defaultRanges={[
167+
{ label: "Last 1 year", type: "years", value: 1 },
168+
{ label: "Last 5 years", type: "years", value: 5 },
169+
{ label: "Last 6 months", type: "months", value: 6 },
170+
]}
171+
enableCustomRange
172+
/>
173+
<BucketAggregation
174+
title="Tags"
175+
agg={{ field: "tags", aggName: "tags_agg" }}
176+
renderValuesContainerElement={customAggValuesContainerCmp}
177+
renderValueElement={customAggValueCmp}
178+
/>
179+
<BucketAggregation
180+
title="Employee Types"
181+
agg={{
182+
field: "employee_type.type",
183+
aggName: "type_agg",
184+
childAgg: {
185+
field: "employee_type.subtype",
186+
aggName: "subtype_agg",
187+
},
188+
}}
189+
/>
190+
</Grid.Column>
191+
<Grid.Column width={12}>
192+
<ResultsLoader>
193+
<EmptyResults />
194+
<Error />
195+
<OnResults />
196+
</ResultsLoader>
197+
</Grid.Column>
198+
</Grid.Row>
199+
</Grid>
200+
</Container>
201+
</ReactSearchKit>
202+
</OverridableContext.Provider>
203+
);
206204
}

src/demos/opensearch/Results.js

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import PropTypes from "prop-types";
10-
import React, { Component } from "react";
1110
import { Grid } from "semantic-ui-react";
1211
import {
1312
ActiveFilters,
@@ -17,35 +16,33 @@ import {
1716
ResultsMultiLayout,
1817
} from "../../lib/components";
1918

20-
export class Results extends Component {
21-
render() {
22-
const { currentResultsState } = this.props;
23-
const { data } = currentResultsState;
24-
const { total } = data;
25-
return total ? (
26-
<>
27-
<Grid relaxed>
28-
<ActiveFilters />
29-
</Grid>
30-
<Grid relaxed verticalAlign="middle">
31-
<Grid.Column width={8}>
32-
<span style={({ marginLeft: "0.5em" }, { marginRight: "0.5em" })}>
33-
<Count label={(cmp) => <>Found {cmp}</>} />
34-
</span>
35-
</Grid.Column>
36-
<Grid.Column width={8} textAlign="right">
37-
<LayoutSwitcher defaultLayout="grid" />
38-
</Grid.Column>
39-
</Grid>
40-
<Grid relaxed style={{ padding: "2em 0" }}>
41-
<ResultsMultiLayout overridableId="opensearch" />
42-
</Grid>
43-
<Grid relaxed verticalAlign="middle" textAlign="center">
44-
<Pagination />
45-
</Grid>
46-
</>
47-
) : null;
48-
}
19+
export function Results(props) {
20+
const { currentResultsState } = props;
21+
const { data } = currentResultsState;
22+
const { total } = data;
23+
return total ? (
24+
<>
25+
<Grid relaxed>
26+
<ActiveFilters />
27+
</Grid>
28+
<Grid relaxed verticalAlign="middle">
29+
<Grid.Column width={8}>
30+
<span style={({ marginLeft: "0.5em" }, { marginRight: "0.5em" })}>
31+
<Count label={(cmp) => <>Found {cmp}</>} />
32+
</span>
33+
</Grid.Column>
34+
<Grid.Column width={8} textAlign="right">
35+
<LayoutSwitcher defaultLayout="grid" />
36+
</Grid.Column>
37+
</Grid>
38+
<Grid relaxed style={{ padding: "2em 0" }}>
39+
<ResultsMultiLayout overridableId="opensearch" />
40+
</Grid>
41+
<Grid relaxed verticalAlign="middle" textAlign="center">
42+
<Pagination />
43+
</Grid>
44+
</>
45+
) : null;
4946
}
5047

5148
Results.propTypes = {

src/demos/zenodo/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import _truncate from "lodash/truncate";
1010
import PropTypes from "prop-types";
11-
import React, { Component } from "react";
11+
import { Component } from "react";
1212
import { OverridableContext } from "react-overridable";
1313
import { Accordion, Card, Container, Grid, Image, Item, Menu } from "semantic-ui-react";
1414
import { InvenioSearchApi } from "../../lib/api/contrib/invenio";

0 commit comments

Comments
 (0)