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, { useReducer } from 'react'; | |
| function reducer(state, action) { | |
| switch (action.type) { | |
| case 'add': | |
| return [...state, action.item]; | |
| case 'remove': | |
| return [ | |
| ...state.slice(0, action.index), | |
| ...state.slice(action.index + 1) |
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
| in package.json | |
| "scripts": { | |
| "dploy": "func() { git add . && git commit -m \"mess - $1\" && git push; }; func", | |
| } | |
| in terminal | |
| npm run dploy -- "message here" |
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 axios from "axios" | |
| export async function handler(event, context) { | |
| try { | |
| const response = await axios.get("https://icanhazdadjoke.com", { headers: { Accept: "application/json" } }) | |
| const data = response.data | |
| return { | |
| statusCode: 200, | |
| body: JSON.stringify({ msg: data.joke }) | |
| } | |
| } catch (err) { |
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 list = new Array(5000).fill(0).map((v, i) => i); |
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
| Si err = HOC import TypeError: Object(…) is not a function | |
| soluce = | |
| import {ContextHoc} from "../../context/ContextHoc" |
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
| Gatsby node > pages by locales + add i18n to context | |
| Page layout context > locales | |
| component Switch lang |
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
| {variableTrue | |
| ? ( | |
| <div> | |
| bla bla | |
| </div> | |
| ) | |
| : ( | |
| undefined | |
| )} |
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
| pb synchro pubsub, n'écoute plus par ex | |
| ajouter un token | |
| this.OPEN_OVERLAY = PubSub.subscribe("OPEN_OVERLAY", this._toggle) | |
| PubSub.unsubscribe(this.OPEN_OVERLAY) |
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
| [1, 2, 3].forEach((val) => console.log(val)); |
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
| getRandomInt(min, max) { | |
| min = Math.ceil(min); | |
| max = Math.floor(max); | |
| return Math.floor(Math.random() * (max - min + 1)) + min; | |
| } |