-
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
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 = { |
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
it("should add the country when number starts with 9", () => { | |
expect(formatNumber("943434")("260")).toEqual("260 943434"); | |
}); | |
it("should format even if the code existed", () => { | |
expect(formatNumber("+260943434")("260")).toEqual("260 943434"); | |
}); | |
it("should format even if number is spaced out", () => { | |
expect(formatNumber("+260 943434")("260")).toEqual("260 943434"); |
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 * as R from 'ramda' | |
const formatNumber = R.compose( | |
appendCountryCode, | |
removePrefix, | |
removeSymbol | |
); | |
// the above function can be called like this | |
formatNumber(numberToformat)(countryCode) |