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'; | |
// the translate hook | |
import { useTranslation } from 'react-i18next'; | |
const MyComponent = () { | |
const { t, i18n } = useTranslation(); | |
return ( | |
<h1>{t('Welcome to React')}</h1> | |
) |
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, { Component } from "react"; | |
import ReactDOM from "react-dom"; | |
import './i18n'; | |
import App from './App'; | |
// append app to dom | |
ReactDOM.render( | |
<App />, | |
document.getElementById("root") |
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 i18n from "i18next"; | |
import { initReactI18next } from "react-i18next"; | |
// the translations | |
// (tip move them in a JSON file and import them) | |
const resources = { | |
en: { | |
translation: { | |
"Welcome to React": "Welcome to React and react-i18next" | |
} |
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 { | |
LineChart, Line, XAxis, CartesianGrid, Tooltip, | |
} from 'recharts'; | |
const Recharts = () => ( | |
<LineChart | |
width={400} | |
height={400} | |
data={data} |
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 { Formik } from 'formik'; | |
const Basic = () => ( | |
<div> | |
<h1>Anywhere in your app!</h1> | |
<Formik | |
initialValues={{ email: '', password: '' }} | |
validate={values => { | |
const errors = {}; |
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 { createStore } from 'redux' | |
/** | |
* This is a reducer, a pure function with (state, action) => state signature. | |
* It describes how an action transforms the state into the next state. | |
* | |
* The shape of the state is up to you: it can be a primitive, an array, an object, | |
* or even an Immutable.js data structure. The only important part is that you should | |
* not mutate the state object, but return a new object if the state changes. | |
* |
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 styled from 'styled-components'; | |
// Create a <Title> react component that renders an <h1> which is | |
// centered, palevioletred and sized at 1.5em | |
const Title = styled.h1` | |
font-size: 1.5em; | |
text-align: center; | |
color: palevioletred; |
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
const User = mongoose.model('User', { name: String, email: String, surname: String }) | |
const AdminBroOptions = { | |
resources: [User], | |
} | |
const AdminBro = new AdminBro(AdminBroOptions) | |
const router = AdminBroExpress.buildRouter(AdminBro) | |
// add router to express |