Skip to content

Support for React 18 #17

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

Merged
merged 3 commits into from
Nov 16, 2022
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
14 changes: 8 additions & 6 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

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

### `npm start`

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

The page will reload if you make edits.<br />
The page will reload if you make edits.\
You will also see any lint errors in the console.

### `npm test`

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

### `npm run build`

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

The build is minified and the filenames include the hashes.<br />
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

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

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.

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.
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.

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.

Expand Down
33 changes: 19 additions & 14 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{
"name": "react-multi-lang-example",
"name": "example",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.2.1",
"@types/jest": "^24.9.1",
"@types/node": "^12.12.26",
"@types/react": "^16.9.19",
"@types/react-dom": "^16.9.5",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0",
"typescript": "^3.7.5",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.3",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-multi-lang": "file:..",
"react-scripts": "5.0.1",
"typescript": "^4.9.3",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
Expand All @@ -22,7 +24,10 @@
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
Expand All @@ -35,5 +40,5 @@
"last 1 firefox version",
"last 1 safari version"
]
},
}
}
1 change: 1 addition & 0 deletions example/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: *
Disallow:
25 changes: 0 additions & 25 deletions example/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,12 @@
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
9 changes: 0 additions & 9 deletions example/src/App.test.tsx

This file was deleted.

12 changes: 4 additions & 8 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import React from 'react';
import { getLanguage, setLanguage, useTranslation } from 'react-multi-lang'
import './App.css';
import logo from './logo.svg';

const App: React.FC = () => {

function App() {
const t = useTranslation()

return (
<div className='App'>
<header className='App-header'>
<img src={logo} className='App-logo' alt='logo' />
<div className="App">
<header className="App-header">
<h1 className='App-title'>
{t('home.Title', {param: 'react'})}
</h1>
Expand All @@ -23,7 +19,7 @@ const App: React.FC = () => {
<button onClick={() => setLanguage('pt')}>PT</button>
<button onClick={() => setLanguage('en')}>EN</button>
</div>
)
);
}

export default App;
25 changes: 13 additions & 12 deletions example/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import './index.css'
import * as serviceWorker from './serviceWorker'
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';

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

setDefaultTranslations({pt, en})
setDefaultTranslations({ pt, en })
setDefaultLanguage('pt')

ReactDOM.render(<App />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
7 changes: 0 additions & 7 deletions example/src/logo.svg

This file was deleted.

145 changes: 0 additions & 145 deletions example/src/serviceWorker.ts

This file was deleted.

5 changes: 0 additions & 5 deletions example/src/setupTests.ts

This file was deleted.

3 changes: 2 additions & 1 deletion example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
"jsx": "react-jsx"
},
"include": [
"src"
Expand Down
Loading