首先建立一个新的目录,并使用yarn init
进行初始化:
mkdir hello-world
yarn init -y
然后安装reskript
:
const {rollup} = require('rollup'); | |
const babel = require('rollup-plugin-babel'); | |
const svgToReact = require('rollup-plugin-svg-to-jsx'); | |
const autoExternal = require('rollup-plugin-auto-external'); | |
const resolve = require('rollup-plugin-node-resolve'); | |
const css = require('rollup-plugin-postcss'); | |
const babelConfig = { | |
presets: [ | |
[ |
首先建立一个新的目录,并使用yarn init
进行初始化:
mkdir hello-world
yarn init -y
然后安装reskript
:
const path = require('path'); | |
const fs = require('fs'); | |
const {execSync} = require('child_process'); | |
const {sync: rimraf} = require('rimraf'); | |
const {sync: glob} = require('glob'); | |
const {mapValues} = require('lodash'); | |
const topLevelModuleNames = glob('src/*/').map(path => path.slice(4, -1)); | |
const replaceImportAlias = content => topLevelModuleNames.reduce( |
// HOC版本 | |
const withDelayHint = (loadingPropName, delay) => ComponentIn => class extends Component { | |
state = { | |
timer: null, | |
isDelayed: false | |
}; | |
tryStartTimer = () => { | |
clearTimeout(this.state.timer); |
[ | |
{ | |
"type": "comment", | |
"text": "/***************************************************************************" | |
}, | |
{ | |
"type": "lineBreak" | |
}, | |
{ | |
"type": "comment", |
import {PureComponent} from 'react'; | |
import PropTypes from 'prop-types'; | |
import {createSelector} from 'reselect'; | |
import {parseDiff, addStubHunk, expandFromRawCode, Diff, Hunk} from 'react-diff-view'; | |
import {push} from 'san-update/fp'; | |
import {diffLines, formatLines} from 'unidiff'; | |
import {property} from 'lodash/fp'; | |
import 'react-diff-view/index.css'; | |
import HunkHeader from './HunkHeader'; |
/** | |
* @file 为一个组件提供初始化时异步获取数据的能力 | |
* @author zhanglili | |
*/ | |
import {PureComponent, createElement} from 'react'; | |
import {zipObject, identity, noop} from 'lodash'; | |
import {wrapDisplayName} from 'recompose'; | |
/** |
功能比较简单,从URL中获取到q
参数并且显示在文本框中,但允许文本框内用户输入其它的搜索词
如果让Input
工作在受控模式下,那么就必须控制value
的同步,也需要componentWillReceiveProps
进行同步,代码较多。如果使用defaultValue
但不提供key
,则会导致URL变化后文本框内容不会更新
一个简易的方法就是使用key
来在URL变化时强制刷新文本框,但同时也能利用defaultValue
简化同步
const pathToRegExp = require('path-to-regexp'); | |
const repo = { | |
index: pathToRegExp('/repos/:organization/:dir/:name'), | |
blob: pathToRegExp('/repos/:organization/:dir/:name/blob/:path+') | |
}; | |
const legacyRepo = { | |
index: pathToRegExp('/repos/:organization/:dir/:name/:extra+'), | |
blob: pathToRegExp('/repos/:organization/:dir/:name/:extra+/blob/:path+') |
babel/arrow-parens | |
babel/generator-star-spacing | |
generator-star-spacing | |
babel/new-cap | |
array-bracket-spacing | |
babel/object-curly-spacing | |
arrow-parens | |
no-console | |
no-constant-condition | |
comma-dangle |