new () => React.Component<any, any>
// example
export const addValidatedFormContainer = (validators: any[] = []) =>
(component: new () => React.Component<any, any>) => flow(
validate(validators),
makeWrapper()
)(component);
This file contains 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 App = () => <div> | |
<h1>My App</h1> | |
</div> | |
export default App; |
This file contains 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
module.exports = { | |
presets: [ | |
require('poi-preset-react')(), | |
] | |
} |
This file contains 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 from 'react'; | |
import { render } from 'react-dom'; | |
import App from './App.jsx'; | |
render(<App />, document.getElementById('app')); |
This file contains 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
sudo: required | |
dist: trusty | |
language: node_js | |
node_js: | |
- "6.9.0" | |
python: | |
- "3.5" | |
cache: | |
- pip | |
- yarn |
This file contains 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 { EventEmitter2 } from 'eventemitter2'; | |
class Core extends EventEmitter2 { | |
constructor() { | |
super(); | |
this.init(); | |
} | |
init() { | |
console.log('initialised'); |
This file contains 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
function isRequired<T extends string> (prop: T, message: string = `${prop} is a required field`) { | |
return [ | |
(model: { [name in T]: any }) => !!model[prop], | |
{ [prop as string]: message } | |
]; | |
} | |
interface Foo { | |
price: 123; | |
desc: 'foo'; |
You generally don't unit test private methods directly. Since they are private, consider them an implementation detail. Nobody is ever going to call one of them and expect it to work a particular way. You should instead test your public interface. If the methods that call your private methods are working as you expect, you then assume by extension that your private methods are working correctly.
This file contains 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
function workerFunction() { | |
this.addEventListener('message', (e) => { | |
console.log('log2: ', e); | |
fetchUrl(e.data); | |
}) | |
const fetchUrl = (url) => { | |
fetch(url) | |
.then((response) => { | |
console.log(response); |
This file contains 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 _ = require('lodash'); | |
class SimpleMapper { | |
constructor(data) { | |
this.data = _.cloneDeep(data); | |
this.mappings = []; | |
this.result = {}; | |
} | |
addMapping(destination, source, transform = v => v) { |