Skip to content

Instantly share code, notes, and snippets.

@Frezc
Frezc / dep-analysis.js
Created September 5, 2020 08:05
yarn依赖分析
const fs = require('fs');
const path = require('path');
const pkg = require('./package.json');
const { execSync } = require('child_process');
const yarntree = JSON.parse(execSync('yarn list --json'));
// 排除的依赖
const exceptList = [
@Frezc
Frezc / bind-props.ts
Created August 8, 2019 08:48
bind props to react component
import { ComponentType, createElement, forwardRef } from "react";
export default function bindProps<P, PP extends Partial<P>, T = any>(Comp: ComponentType<P>, props: PP) {
return forwardRef<T, Omit<P, keyof PP> & Partial<PP>>((p, ref) => createElement(Comp, Object.assign({ ref }, props, p) as unknown as P))
}