Skip to content

simple-react-snippets

SnippetRenders
imrImport React
imrcImport React / Component
imptImport PropTypes
impcImport React / PureComponent
ccClass Component
cccClass Component With Constructor
sfcStateless Function Component
cdmcomponentDidMount
cwmcomponentWillMount
cwrpcomponentWillReceiveProps
gdsgetDerivedStateFromProps
scushouldComponentUpdate
cwucomponentWillUpdate
cducomponentDidUpdate
cwucomponentWillUpdate
cdccomponentDidCatch
gsbugetSnapshotBeforeUpdate
sssetState
ssfFunctional setState
renrender
rpropRender Prop
hocHigher Order Component

hoc

javascript
function | (|) {
  return class extends Component {
    constructor(props) {
      super(props);
    }

    render() {
      return < | {...this.props} />;
    }
  };
}

sfc

javascript
const | = props => {
  return ( | );
};

export default |;

ccc - Class Component With Constructor

javascript
function | (|) {
  return class extends Component {
    constructor(props) {
      super(props);
    }

    render() {
      return < | {...this.props} />;
    }
  };
}

cc - Class Component

javascript
class | extends Component {
 state = { | },
 render() {
   return ( | );
 }
}
export default |;

更新: 2019-11-08 14:24:15
原文: https://www.yuque.com/u3641/dxlfpu/fxxgfa