Jest cheat sheet
https://github.com/sapegin/jest-cheat-sheet
Access component method
wrapper.instance().componentMethod
(function (global, factory) { | |
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) : | |
typeof define === 'function' && define.amd ? define(['react'], factory) : | |
(global.ReactDOM = factory(global.React)); | |
}(this, (function (React) { |
// modules are defined as an array | |
// [ module function, map of requires ] | |
// | |
// map of requires is short require name -> numeric require | |
// | |
// anything defined in a previous bundle is accessed via the | |
// orig method which is the require for previous bundles | |
// eslint-disable-next-line no-global-assign | |
require = (function (modules, cache, entry) { |
Jest cheat sheet
https://github.com/sapegin/jest-cheat-sheet
Access component method
wrapper.instance().componentMethod
In the present, web services almost build based on microservice architecture, separate front end node app and back end api, this will cause cors issue while developing and distributing production, that's go through some basic solution for dealing with cors.
By default json-server is launch with cors enabled, so directly fetch data from API server.
const mouseDownEvent = document.createEvent('MouseEvents'); | |
mouseDownEvent.initEvent('mousedown', true, true); | |
let activeSquares = []; | |
function obsRoot() { | |
const root = document.getElementsByClassName('squares')[0]; | |
const rootObserver = new MutationObserver((mutations) => mutations.map(mutation => { | |
obsSquares(); | |
})); |
/* global document, gapi, Promise */ | |
import React, { PureComponent } from 'react'; | |
class App extends PureComponent { | |
constructor(props) { | |
super(props); | |
this.state = { gapiReady: false, values: {} }; | |
} | |
initGoogleAPI = () => { |
function fillParamsIntoPath (path, ...params) { | |
let i = -1; | |
return path.replace(/\/\:\w{1,}/ig, () => { | |
i += 1; | |
return `\/${params[i]}`; | |
}); | |
} | |
console.log(fillParamsIntoPath('https://localhost:3000/api/members/:id', 1)); | |
console.log(fillParamsIntoPath('/api/members/:member_id/friends/:friend_id', 1, 2)); |
日期 | 不重複瀏覽量 | |
---|---|---|
6/2 | 41,227 | |
6/3 | 303,348 | |
6/4 | 193,096 | |
6/5 | 77,828 | |
6/6 | 32,123 | |
6/7 | 16,969 | |
6/8 | 9,360 |
[{"id":1,"jp":"フシギダネ","en":"Bulbasaur","tw":"妙蛙種子"},{"id":2,"jp":"フシギソウ","en":"Ivysaur","tw":"妙蛙草"},{"id":3,"jp":"フシギバナ","en":"Venusaur","tw":"妙蛙花"},{"id":4,"jp":"ヒトカゲ","en":"Charmander","tw":"小火龍"},{"id":5,"jp":"リザード","en":"Charmeleon","tw":"火恐龍"},{"id":6,"jp":"リザードン","en":"Charizard","tw":"噴火龍"},{"id":7,"jp":"ゼニガメ","en":"Squirtle","tw":"傑尼龜"},{"id":8,"jp":"カメール","en":"Wartortle","tw":"卡咪龜"},{"id":9,"jp":"カメックス","en":"Blastoise","tw":"水箭龜"},{"id":10,"jp":"キャタピー","en":"Caterpie","tw":"綠毛蟲"},{"id":11,"jp":"トランセル","en":"Metapod","tw":"鐵甲蛹"},{"id":12,"jp":"バタフリー","en":"Butterfree","tw":"巴大蝴"},{"id":13,"jp":"ビードル","en":"Weedle","tw":"獨角蟲"},{"id":14,"jp":"コクーン","en":"Kakuna","tw":"鐵殼昆"},{"id":15,"jp":"スピアー","en":"Beedrill","tw":"大針蜂"},{"id":16,"jp":"ポッポ","en":"Pidgey","tw":"波波"},{"id":17,"jp":"ピジョン","en":"Pidgeotto","tw":"比比鳥"},{"id":18,"jp":"ピジョット","en":"Pidgeot","tw":"比鵰"},{"id":19,"jp":"コラッタ","en":"Rattata","tw":"小拉達"},{"id":20,"jp":"ラッタ","en":"Raticate","tw":"拉達"},{"id":21,"jp":"オニスズメ","en":"Spearow","
const updateTitle = title => { | |
return async dispatch => { | |
dispatch({ type: UPDATE_TITLE }); | |
try { | |
const res = await fetch(url, { | |
method: 'PUT', | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json' | |
}, |