-
Briefly explain the difference between props and states
-
What are synthetic events in React?
-
What are refs and give example of a use case?
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 { ApolloServer, gql } = require("apollo-server"); | |
const jwt = require("jsonwebtoken"); | |
const mongoose = require("mongoose"); | |
const bcrypt = require("bcrypt"); | |
const pick = require("lodash").pick; | |
// configure the user collection | |
const userSchema = mongoose.Schema({ | |
email: String, | |
password: String |
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 SECRET="createaverystrongsecretthatalsoincludes2423412wdsa324e34e" | |
const server = new ApolloServer({ | |
schema, | |
context: ({ req }) => { | |
const { user } = req | |
// the user and secret we are passing here is what we access in every resolver | |
return { | |
user, | |
SECRET, |
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
Mutation: { | |
async register(root, { email, password }) { | |
// { email, password } this is coming from the args(arguments) that are passed down when registering | |
let user = new User() | |
user.email = email | |
// here we hash the password using bcrypt and store the hashed value in the db | |
user.password = await bcrypt.hash(password, 12) | |
// save the user to the db | |
// it shouldn't matter what db you are using | |
return user.save() |
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
<ErrorBoundary> | |
<ComponentThatCanCauseAnError /> | |
{ /* If you want you can even nest this */ } | |
<ErrorBoundary> | |
<AnotherComponent /> | |
</ErrorBoundary> | |
</ErrorBoundary> | |
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 { PropTypes } from 'prop-types'; | |
import { Meteor } from 'meteor/meteor'; | |
import { formatText } from '../utils/utils'; | |
export default class ErrorBoundary extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { hasError: false }; | |
} |
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
"titles": { | |
"addreference": "Ajouter Références", | |
"referenceDisplaced": "Références affichées", | |
"feedback": "Commentaire", | |
"source": "Source", | |
"usersfeedback": "Commentaires de l'utilisateur", | |
"notifications": "Notifications", | |
"bookmarks": "Signets" | |
} |
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
// this is truncated and don't mind this comment in JSON 😉 | |
{ | |
"_locale": "en-us", | |
"_namespace": "common", | |
"language": { | |
"enUS": "English - U.S.", | |
"esES": "Spanish - SP", | |
"frFr": "French - FR", | |
"Language": "Language" | |
}, |
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
// This file has been truncated for brevity | |
import React, { Fragment, Component } from 'react'; | |
import { Meteor } from 'meteor/meteor'; | |
import PropTypes from 'prop-types'; | |
import i18n from 'meteor/universe:i18n'; | |
import { ThemeContext } from '../../containers/AppWrapper'; | |
const T = i18n.createComponent(); |
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
/* eslint class-methods-use-this: "off" */ | |
/* eslint import/no-unresolved: "off" */ | |
import React, { Fragment } from 'react'; | |
import { PropTypes } from 'prop-types'; | |
import Header from '../components/layouts/Header'; | |
export const ThemeContext = React.createContext(); | |
export default class AppWrapper extends React.Component { | |
state = { |