This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useContext } from 'react'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
import { I18nContext } from './i18n'; | |
import LanguageSelect from './components/LanguageSelect'; | |
const App = () => { | |
const { translate } = useContext(I18nContext); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import "./index.css"; | |
import App from "./App"; | |
import * as serviceWorker from "./serviceWorker"; | |
import { I18nContextProvider } from "./i18n"; | |
// Nothing fancy, just wrap the App | |
ReactDOM.render( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// some other imports | |
import LanguageSelect from "./components/LanguageSelect"; | |
// some other code | |
// <img src={logo} className="App-logo" alt="logo" /> | |
<LanguageSelect /> // Add LanguageSelect component here! | |
//<p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useContext } from "react"; | |
import { I18nContext } from "../i18n"; | |
const LanguageSelect = props => { | |
/* Another hook here: useContext will receive a Context | |
and return anything provided in the Provider */ | |
const { langCode, dispatch } = useContext(I18nContext); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useReducer } from "react"; | |
import EN from "./en.json"; | |
import TR from "./tr.json"; | |
import ES from "./es.json"; | |
// To make it easier to read from JSON files | |
const translations = { | |
en: EN, | |
tr: TR, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"edit_and_save": "Edit src/App.js and save to reload.", | |
"learn_react": "Learn React" | |
} |