Skip to content

Instantly share code, notes, and snippets.

View LissetteIbnz's full-sized avatar
:electron:
Focus

Sara Lissette LissetteIbnz

:electron:
Focus
View GitHub Profile
/**
* TypeScript version of @istarkov's cancellable Promise wrapper.
*
* @see https://github.com/facebook/react/issues/5465#issuecomment-157888325
*/
const makeCancelable = <T>(promise: Promise<T>): { promise: Promise<T>; cancel(): void } => {
let hasCanceled = false;
const wrappedPromise = new Promise<T>((resolve, reject) => {
promise.then(
@LissetteIbnz
LissetteIbnz / ShareCom.js
Created March 27, 2019 14:36 — forked from wahengchang/ShareCom.js
Unit test, mocking components
import { InstallCom } from 'installComponent' //installed by npm
import UserCom from './userComponent'
export class ShareCom extends Component {
render() {
return (
<div>
<InstallCom para1='title1'/>
<UserCom para2='title2' />
</div>
@LissetteIbnz
LissetteIbnz / Fetch.test.js
Created March 6, 2019 14:06 — forked from alfonsomunozpomer/Fetch.test.js
How to test a React component that sets its state in componentDidMount with fetch, and how to mock it, in Jest
// https://github.com/alfonsomunozpomer/react-fetch-mock
import React from 'react'
import fetchMock from 'fetch-mock'
import Enzyme from 'enzyme'
import {shallow, mount, render} from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
Enzyme.configure({ adapter: new Adapter() })
@LissetteIbnz
LissetteIbnz / es6-import-cheat-sheet.md
Created January 4, 2019 10:38 — forked from samueljseay/es6-import-cheat-sheet.md
ES6 exports / imports cheat sheet
// default exports
export default 42;
export default {};
export default [];
export default (1 + 2);
export default foo;
export default function () {}
export default class {}
export default function foo () {}