Skip to content

Commit

Permalink
feat: update to CRA4 and React 17
Browse files Browse the repository at this point in the history
Update to use latest versions from create-react-app and react. It also contains a refactor, cleaning unneeded React references. Also, as a small addition, I have removed the numeric zoom label from ZoomControl in skeleton template (as in sample-app)

Co-authored-by: VictorVelarde <[email protected]>
  • Loading branch information
aaranadev and VictorVelarde authored Feb 2, 2021
1 parent ab3a5cc commit f0ca990
Show file tree
Hide file tree
Showing 41 changed files with 162 additions and 493 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ template-skeleton/README.md
/template-skeleton/template/yarn.lock
/template-skeleton/template/node_modules
/template-skeleton/template/_templates
/template-skeleton/template/.eslintcache

template-sample-app/README.md
/template-sample-app/yarn.lock
/template-sample-app/template/package.json
/template-sample-app/template/yarn.lock
/template-sample-app/template/node_modules
/template-sample-app/template/_templates
/template-sample-app/template/.eslintcache

# dependencies
node_modules
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Refactor source structure for simplification [#164](https://github.com/CartoDB/carto-react-template/issues/164)
- Add basic e2e tests to both sample-app and skeleton with cypress [#169](https://github.com/CartoDB/carto-react-template/pull/169)
- Update deck.gl version to 8.4 [#184](https://github.com/CartoDB/carto-react-template/pull/184)
- Update to CRA4 and React 17 [#186](https://github.com/CartoDB/carto-react-template/pull/186)

## 1.0.0-beta10 (2021-01-16)
- Fix missing babel dependencies when using CRA for both templates [#160](https://github.com/CartoDB/carto-react-template/issues/160)
Expand Down
75 changes: 31 additions & 44 deletions template-sample-app/template.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,53 @@
{
"package": {
"dependencies": {
"@babel/helper-builder-react-jsx": "^7.10.4",
"@babel/plugin-transform-react-jsx": "^7.12.12",
"@carto/react": "^1.0.0-beta12",
"@formatjs/intl-getcanonicallocales": "^1.5.2",
"@formatjs/intl-locale": "^2.4.8",
"@formatjs/intl-numberformat": "^6.0.0",
"@formatjs/intl-pluralrules": "^4.0.0",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@carto/react": "1.0.0-beta12",
"@formatjs/intl-getcanonicallocales": "^1.5.3",
"@formatjs/intl-locale": "^2.4.14",
"@formatjs/intl-numberformat": "^6.1.4",
"@formatjs/intl-pluralrules": "^4.0.6",
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "4.0.0-alpha.57",
"@reduxjs/toolkit": "^1.5.0",
"@testing-library/cypress": "^7.0.3",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.3",
"@testing-library/user-event": "^12.6.2",
"cypress": "^6.3.0",
"deck.gl": "^8.4.0",
"echarts": "^4.9.0",
"echarts-for-react": "^2.0.16",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.3.1",
"firebase-tools": "^9.2.2",
"history": "^5.0.0",
"react": "^16.13.1",
"husky": "^4.3.8",
"hygen": "^6.0.4",
"lint-staged": "^10.5.3",
"prettier": "^2.2.1",
"react": "^17.0.1",
"react-app-polyfill": "^2.0.0",
"react-dom": "^16.13.1",
"react-map-gl": "^5.2.8",
"react-redux": "^7.1.3",
"react-app-rewired": "^2.1.8",
"react-dom": "^17.0.1",
"react-is": "^17.0.1",
"react-map-gl": "^5.3.0",
"react-redux": "^7.2.2",
"react-router-dom": "^6.0.0-beta.0",
"react-scripts": "3.4.3",
"eslint-config-prettier": "^6.12.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.2",
"husky": "^4.3.0",
"lint-staged": "^10.4.0",
"prettier": "^2.1.2",
"react-app-rewired": "^2.1.6",
"hygen": "^6.0.4"
"react-scripts": "4.0.1"
},
"scripts": {
"lint": "eslint './src/**/*.{js,jsx}'",
"lint:fix": "eslint './src/**/*.{js,jsx}' --fix",
"format": "npx prettier --write \"**/*.+(js|jsx|json|css|md)\"",
"format": "prettier --write \"**/*.+(js|jsx|json|css|md)\" --ignore-path .gitignore",
"hygen": "hygen",
"updateSupportedBrowsers": "echo \"var browserRegex = $(npx browserslist-useragent-regexp --allowHigherVersions);\" > public/supportedBrowsers.js"
},
"eslintConfig": {
"extends": "react-app"
"extends": ["react-app", "prettier", "prettier/react"]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all",
"not explorer 11"
],
"production": [">0.2%", "not dead", "not op_mini all", "not explorer 11"],
"development": [
"last 1 chrome version",
"last 1 firefox version",
Expand All @@ -67,14 +60,8 @@
}
},
"lint-staged": {
"*.+(js|jsx)": [
"yarn lint:fix",
"git add"
],
"*.+(js|jsx|json|css|md)": [
"prettier --write",
"git add"
]
"*.+(js|jsx)": ["yarn lint:fix", "git add"],
"*.+(js|jsx|json|css|md)": ["prettier --write", "git add"]
}
}
}
}
1 change: 1 addition & 0 deletions template-sample-app/template/gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package.dev.json
config-overrides.js
storybook-static
.eslintcache

# dependencies
/node_modules
Expand Down
54 changes: 25 additions & 29 deletions template-sample-app/template/package.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,41 @@
"version": "1.0.0-beta12",
"private": true,
"dependencies": {
"@carto/react": "^1.0.0-beta12",
"@formatjs/intl-getcanonicallocales": "^1.5.2",
"@formatjs/intl-locale": "^2.4.8",
"@formatjs/intl-numberformat": "^6.0.0",
"@formatjs/intl-pluralrules": "^4.0.0",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@carto/react": "1.0.0-beta12",
"@formatjs/intl-getcanonicallocales": "^1.5.3",
"@formatjs/intl-locale": "^2.4.14",
"@formatjs/intl-numberformat": "^6.1.4",
"@formatjs/intl-pluralrules": "^4.0.6",
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "4.0.0-alpha.57",
"@reduxjs/toolkit": "^1.5.0",
"@testing-library/cypress": "^7.0.3",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.3",
"@testing-library/user-event": "^12.6.2",
"cypress": "^6.3.0",
"deck.gl": "^8.4.0",
"echarts": "^4.9.0",
"echarts-for-react": "^2.0.16",
"history": "^5.0.0",
"react": "^16.13.1",
"react": "^17.0.1",
"react-app-polyfill": "^2.0.0",
"react-dom": "^16.13.1",
"react-map-gl": "^5.2.8",
"react-redux": "^7.1.3",
"react-dom": "^17.0.1",
"react-map-gl": "^5.3.0",
"react-redux": "^7.2.2",
"react-router-dom": "^6.0.0-beta.0",
"react-scripts": "3.4.3"
"react-scripts": "4.0.1"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"babel-loader": "8.1.0",
"eslint-config-prettier": "^6.12.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.2",
"firebase-tools": "^8.16.2",
"husky": "^4.3.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.3.1",
"firebase-tools": "^9.2.2",
"husky": "^4.3.8",
"hygen": "^6.0.4",
"lint-staged": "^10.4.0",
"prettier": "^2.1.2",
"react-app-rewired": "^2.1.6",
"lint-staged": "^10.5.3",
"prettier": "^2.2.1",
"react-app-rewired": "^2.1.8",
"react-is": "^17.0.1"
},
"scripts": {
Expand All @@ -52,12 +48,12 @@
"eject": "react-scripts eject",
"lint": "eslint './src/**/*.{js,jsx}'",
"lint:fix": "eslint './src/**/*.{js,jsx}' --fix",
"format": "npx prettier --write \"**/*.+(js|jsx|json|css|md)\"",
"format": "prettier --write \"**/*.+(js|jsx|json|css|md)\" --ignore-path .gitignore",
"hygen": "hygen",
"updateSupportedBrowsers": "echo \"var browserRegex = $(npx browserslist-useragent-regexp --allowHigherVersions);\" > public/supportedBrowsers.js"
},
"eslintConfig": {
"extends": "react-app"
"extends": ["react-app", "prettier", "prettier/react"]
},
"browserslist": {
"production": [">0.2%", "not dead", "not op_mini all", "not explorer 11"],
Expand Down
5 changes: 3 additions & 2 deletions template-sample-app/template/public/robots.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
1 change: 0 additions & 1 deletion template-sample-app/template/src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { useRoutes } from 'react-router-dom';

Expand Down
6 changes: 3 additions & 3 deletions template-sample-app/template/src/components/common/Header.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
import {
AppBar,
Drawer,
Expand Down Expand Up @@ -61,7 +61,7 @@ const NavigationMenu = (props) => {
const classes = useStyles();

return (
<React.Fragment>
<>
<Grid
container
direction={vertical ? 'column' : 'row'}
Expand All @@ -79,7 +79,7 @@ const NavigationMenu = (props) => {
{/* Auto import links */}
</Tabs>
</Grid>
</React.Fragment>
</>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';

import {
Button,
Expand Down
1 change: 0 additions & 1 deletion template-sample-app/template/src/components/common/Map.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { useSelector, useDispatch } from 'react-redux';
import DeckGL from '@deck.gl/react';
import 'mapbox-gl/dist/mapbox-gl.css';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback } from 'react';
import { useCallback } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Button, ButtonGroup, makeStyles } from '@material-ui/core';
import AddOutlinedIcon from '@material-ui/icons/AddOutlined';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { Grid, Typography, makeStyles } from '@material-ui/core';
import rgbToHex from '../../utils/rgbToHex';
Expand Down Expand Up @@ -32,7 +31,7 @@ export default function KpiLegend() {
if (!kpiLayer) return null;

return (
<React.Fragment>
<>
<Typography className={classes.title} variant='caption'>
Total revenue
</Typography>
Expand All @@ -54,6 +53,6 @@ export default function KpiLegend() {
{LABELS[i]}
</Grid>
))}
</React.Fragment>
</>
);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';
import KpiLegend from './KpiLegend';
import StoresLegend from './StoresLegend';
import { Paper, makeStyles, useMediaQuery, useTheme } from '@material-ui/core';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { useSelector } from 'react-redux';

import { Grid, Typography, makeStyles } from '@material-ui/core';
Expand Down Expand Up @@ -34,7 +33,7 @@ export default function StoresLegend() {
if (!storesLayer) return null;

return (
<React.Fragment>
<>
<Typography className={classes.title} variant='caption'>
Store types
</Typography>
Expand All @@ -55,6 +54,6 @@ export default function StoresLegend() {
{elem[0]}
</Grid>
))}
</React.Fragment>
</>
);
}
2 changes: 1 addition & 1 deletion template-sample-app/template/src/components/views/Kpi.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { setBottomSheetOpen, setError } from 'config/appSlice';

Expand Down
8 changes: 3 additions & 5 deletions template-sample-app/template/src/components/views/Main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import { useRef } from 'react';
import { Outlet } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import {
Expand Down Expand Up @@ -185,10 +185,8 @@ export default function Main() {
const classes = useStyles();
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('xs'));
const mobileContainer = React.useRef(null);
const desktopContainer = React.useRef(null);

// Auto import useEffect
const mobileContainer = useRef(null);
const desktopContainer = useRef(null);

// Auto import useEffect

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { Button, Container, Grid, Link, Typography } from '@material-ui/core';
import { NavLink } from 'react-router-dom';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useState } from 'react';

import { useState } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import {
Button,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';
import { useSelector, useDispatch } from 'react-redux';

import { makeStyles } from '@material-ui/core/styles';
Expand Down Expand Up @@ -68,7 +68,7 @@ function UserMenu() {

// Display User menu, with name, avatar + an attached menu for user-related options
return (
<React.Fragment>
<>
<Link
edge='end'
aria-label='account of current user'
Expand Down Expand Up @@ -105,7 +105,7 @@ function UserMenu() {
<MenuItem onClick={handleLogout}>Logout</MenuItem>
<MenuItem onClick={goToCarto}>Go to CARTO</MenuItem>
</Menu>
</React.Fragment>
</>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { Button, Hidden, IconButton } from '@material-ui/core';
import AccountCircleOutlinedIcon from '@material-ui/icons/AccountCircleOutlined';
Expand Down
Loading

1 comment on commit f0ca990

@vercel
Copy link

@vercel vercel bot commented on f0ca990 Feb 2, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.