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
{ | |
"pt-BR": { | |
"title": "Faróis", | |
"content": "Conheça os mais lindos faróis do mundo.", | |
"figure": { | |
"alt": "Foto de farol" | |
} | |
} | |
} |
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
{ | |
"en": { | |
"title": "Lighthouses", | |
"content": "Know the most beautiful lighthouses of the world.", | |
"figure": { | |
"alt": "Lighthouse picture" | |
} | |
} | |
} |
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 i18n from 'i18next'; | |
import LanguageDetector from 'i18next-browser-languagedetector'; | |
import { pt, en } from './locales'; | |
const options = { | |
interpolation: { | |
escapeValue: false, // not needed for react!! | |
}, | |
debug: true, |
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 from 'react'; | |
import AppProvider from './components/context/AppProvider'; | |
import { I18nextProvider } from 'react-i18next'; | |
import i18n from './i18n'; | |
import Router from './components/Router'; | |
import Toolbar from './components/Toolbar'; | |
import './styles/styles.css'; | |
const App = () => ( | |
<div className='wrapper'> |
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 from 'react'; | |
import photo from './photo.jpg'; | |
const Home = () => ( | |
<div className='preview'> | |
<h1>Lighthouses</h1> | |
<div className="cover"> | |
<figure className='center'> | |
<img src={photo} alt="Lighthouse picture"/> | |
</figure> |
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 from 'react'; | |
import { translate } from 'react-i18next'; | |
import photo from './photo.jpg'; | |
const Home = ({ t }) => ( | |
<div className='preview'> | |
<h1>{t('home.title')}</h1> | |
<div> | |
<figure className='center'> | |
<img src={photo} alt={t('home.figure.alt')} /> |
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 PropTypes from 'prop-types'; | |
import fetchPosts from './services/fetchPosts'; | |
function App() { | |
const [posts, setPosts] = useState([]); | |
useEffect(() => { | |
let mounted = true; |
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 axios from 'axios'; | |
const BASE_URL = 'https://jsonplaceholder.typicode.com/posts'; | |
export default async () => { | |
const response = await axios.get(BASE_URL); | |
return response.data; | |
} |
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
export default { | |
get: jest.fn(() => Promise.resolve({ | |
data: [ | |
{ | |
id: 1, | |
title: 'This is a tech post', | |
}, | |
{ | |
id: 2, | |
title: 'Post about testing code', |
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 fetchPosts from './fetchPosts'; | |
import mockedAxios from 'axios'; | |
describe('fetchPosts', () => { | |
it('fetch the posts', async () => { | |
const posts = await fetchPosts(); | |
const expectedResponse = [ | |
{ | |
id: 1, |
OlderNewer