Skip to content

Commit 8bf07f7

Browse files
authored
Merge pull request #17 from joaogsleite/react-18
Support for React 18
2 parents faea925 + cc8f69b commit 8bf07f7

14 files changed

+601
-325
lines changed

example/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Getting Started with Create React App
2+
13
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
24

35
## Available Scripts
@@ -6,23 +8,23 @@ In the project directory, you can run:
68

79
### `npm start`
810

9-
Runs the app in the development mode.<br />
11+
Runs the app in the development mode.\
1012
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
1113

12-
The page will reload if you make edits.<br />
14+
The page will reload if you make edits.\
1315
You will also see any lint errors in the console.
1416

1517
### `npm test`
1618

17-
Launches the test runner in the interactive watch mode.<br />
19+
Launches the test runner in the interactive watch mode.\
1820
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
1921

2022
### `npm run build`
2123

22-
Builds the app for production to the `build` folder.<br />
24+
Builds the app for production to the `build` folder.\
2325
It correctly bundles React in production mode and optimizes the build for the best performance.
2426

25-
The build is minified and the filenames include the hashes.<br />
27+
The build is minified and the filenames include the hashes.\
2628
Your app is ready to be deployed!
2729

2830
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
@@ -33,7 +35,7 @@ See the section about [deployment](https://facebook.github.io/create-react-app/d
3335

3436
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
3537

36-
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
38+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
3739

3840
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
3941

example/package.json

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
{
2-
"name": "react-multi-lang-example",
2+
"name": "example",
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@testing-library/jest-dom": "^4.2.4",
7-
"@testing-library/react": "^9.4.0",
8-
"@testing-library/user-event": "^7.2.1",
9-
"@types/jest": "^24.9.1",
10-
"@types/node": "^12.12.26",
11-
"@types/react": "^16.9.19",
12-
"@types/react-dom": "^16.9.5",
13-
"react": "^16.12.0",
14-
"react-dom": "^16.12.0",
15-
"react-scripts": "3.3.0",
16-
"typescript": "^3.7.5",
6+
"@testing-library/jest-dom": "^5.16.5",
7+
"@testing-library/react": "^13.4.0",
8+
"@testing-library/user-event": "^13.5.0",
9+
"@types/jest": "^27.5.2",
10+
"@types/node": "^16.18.3",
11+
"@types/react": "^18.0.25",
12+
"@types/react-dom": "^18.0.9",
13+
"react": "^18.2.0",
14+
"react-dom": "^18.2.0",
15+
"react-multi-lang": "file:..",
16+
"react-scripts": "5.0.1",
17+
"typescript": "^4.9.3",
18+
"web-vitals": "^2.1.4"
1719
},
1820
"scripts": {
1921
"start": "react-scripts start",
@@ -22,7 +24,10 @@
2224
"eject": "react-scripts eject"
2325
},
2426
"eslintConfig": {
25-
"extends": "react-app"
27+
"extends": [
28+
"react-app",
29+
"react-app/jest"
30+
]
2631
},
2732
"browserslist": {
2833
"production": [
@@ -35,5 +40,5 @@
3540
"last 1 firefox version",
3641
"last 1 safari version"
3742
]
38-
},
43+
}
3944
}

example/public/robots.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# https://www.robotstxt.org/robotstxt.html
22
User-agent: *
3+
Disallow:

example/src/App.css

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,12 @@
22
text-align: center;
33
}
44

5-
.App-logo {
6-
height: 40vmin;
7-
pointer-events: none;
8-
}
9-
10-
@media (prefers-reduced-motion: no-preference) {
11-
.App-logo {
12-
animation: App-logo-spin infinite 20s linear;
13-
}
14-
}
15-
165
.App-header {
176
background-color: #282c34;
18-
min-height: 100vh;
197
display: flex;
208
flex-direction: column;
219
align-items: center;
2210
justify-content: center;
2311
font-size: calc(10px + 2vmin);
2412
color: white;
2513
}
26-
27-
.App-link {
28-
color: #61dafb;
29-
}
30-
31-
@keyframes App-logo-spin {
32-
from {
33-
transform: rotate(0deg);
34-
}
35-
to {
36-
transform: rotate(360deg);
37-
}
38-
}

example/src/App.test.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

example/src/App.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import React from 'react';
22
import { getLanguage, setLanguage, useTranslation } from 'react-multi-lang'
33
import './App.css';
4-
import logo from './logo.svg';
5-
6-
const App: React.FC = () => {
74

5+
function App() {
86
const t = useTranslation()
9-
107
return (
11-
<div className='App'>
12-
<header className='App-header'>
13-
<img src={logo} className='App-logo' alt='logo' />
8+
<div className="App">
9+
<header className="App-header">
1410
<h1 className='App-title'>
1511
{t('home.Title', {param: 'react'})}
1612
</h1>
@@ -23,7 +19,7 @@ const App: React.FC = () => {
2319
<button onClick={() => setLanguage('pt')}>PT</button>
2420
<button onClick={() => setLanguage('en')}>EN</button>
2521
</div>
26-
)
22+
);
2723
}
2824

2925
export default App;

example/src/index.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
import React from 'react'
2-
import ReactDOM from 'react-dom'
3-
import App from './App'
4-
import './index.css'
5-
import * as serviceWorker from './serviceWorker'
1+
import React from 'react';
2+
import ReactDOM from 'react-dom/client';
3+
import './index.css';
4+
import App from './App';
65

76
import { setDefaultLanguage, setDefaultTranslations } from 'react-multi-lang'
87
import en from './translations/en.json'
98
import pt from './translations/pt.json'
109

11-
setDefaultTranslations({pt, en})
10+
setDefaultTranslations({ pt, en })
1211
setDefaultLanguage('pt')
1312

14-
ReactDOM.render(<App />, document.getElementById('root'));
15-
16-
// If you want your app to work offline and load faster, you can change
17-
// unregister() to register() below. Note this comes with some pitfalls.
18-
// Learn more about service workers: https://bit.ly/CRA-PWA
19-
serviceWorker.unregister();
13+
const root = ReactDOM.createRoot(
14+
document.getElementById('root') as HTMLElement
15+
);
16+
root.render(
17+
<React.StrictMode>
18+
<App />
19+
</React.StrictMode>
20+
);

example/src/logo.svg

Lines changed: 0 additions & 7 deletions
This file was deleted.

example/src/serviceWorker.ts

Lines changed: 0 additions & 145 deletions
This file was deleted.

example/src/setupTests.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

example/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
"allowSyntheticDefaultImports": true,
1313
"strict": true,
1414
"forceConsistentCasingInFileNames": true,
15+
"noFallthroughCasesInSwitch": true,
1516
"module": "esnext",
1617
"moduleResolution": "node",
1718
"resolveJsonModule": true,
1819
"isolatedModules": true,
1920
"noEmit": true,
20-
"jsx": "react"
21+
"jsx": "react-jsx"
2122
},
2223
"include": [
2324
"src"

0 commit comments

Comments
 (0)