antd

做表单动态赋值时,如果有错误提示时,不能直接赋值,需要通过setFieldsValue,或者 this.props.form.resetFields

    this.props.form.setFieldsValue({
      hospital:params.hospital
    })

或者

   this.props.form.resetFields('hospital')

react

删除某个state

this.setState((prevState, props) => {
    delete prevState.prop;
    return prevState;
});
delete this.state.prop;
this.setState({})

父组件调用自附件方法

 const { form } = this.formRef.props;
    form.validateFields((err, fieldsValue) => {
      if (err) {
        return;
      }

      console.log('Received values of form: ', values);
      form.resetFields();
      this.setState({ visible: false });
    });

  saveFormRef = formRef => {
    this.formRef = formRef;
  };



....
 <CreateSubject
          wrappedComponentRef={this.saveFormRef}
          visible={this.state.visible}
          onCancel={this.handleCancel}
          onCreate={this.handleCreate}
/>

react dom懒加载

  1. react-virtualized

List.example

react-virtualized

react长列表优化方案: react-virtualized

  1. react-lazyload

react-lazyload

在 react 项目中引入全局变量

方法一:浏览器全局变量 方法二:webpack ProvidePlugin

module.exports = {
  resolve: {
    extensions: ['.js', '.json'],
    alias: {
      Config: path.resolve(__dirname, '../src/utils/Config')
    }
  },
  plugins: [
    new ExtractTextPlugin("styles.css"),
    new webpack.ProvidePlugin({
      Config: "Config"
    }),
  ],
  module: {
  }
};

在 react 项目中引入全局变量