Created
December 9, 2019 23:18
-
-
Save alejovdev/986d18cb87ea6f2644e78b3821c4ce31 to your computer and use it in GitHub Desktop.
This file contains 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, { useState, useEffect } from "react"; | |
import { firestore } from "./firebase"; | |
function App() { | |
const [title, setTitle] = useState(null); | |
const [lang, setLang] = useState("en"); | |
useEffect(() => getTitle(), []); | |
const getTitle = async () => { | |
let res = await firestore | |
.collection("translations") | |
.doc("title") | |
.get(); | |
setTitle(res.data().translated); | |
}; | |
return ( | |
<div className="app"> | |
<header className="title">{title !== null && title[lang]}</header> | |
<select | |
name="langSelect" | |
id="langSelect" | |
onChange={e => setLang(e.target.value)} | |
> | |
<option value="en">English</option> | |
<option value="es">Español</option> | |
<option value="fr">Français</option> | |
</select> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment