小编Jay*_*Jay的帖子

配置Webpack dev服务器,以便能够使用Express提供的API路由,这些路由需要通过Passport授权

这是我的路由结构:

在使用Express服务器并从CLI构建bundle.js时,一切正常,但为了加快开发,我现在想要使用Webpack dev服务器,现在需要以一种方式配置事物.考虑已设置的Passport授权.

这是我的Webpack配置:

module.exports = {
  entry: [
    './client/src/index.js'
  ],
  output: {
    path: __dirname + '/server/public',
    publicPath: '/',
    filename: 'bundle.js'
  },
  module: {
    loaders: [{
      exclude: /node_modules/,
      loader: 'babel'
    }]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  devServer: {
    historyApiFallback: true,
    contentBase: './client'//,
    // proxy: {
    //   '/api/*': {
    //     target: 'http://localhost:3000',
    //     secure: false …
Run Code Online (Sandbox Code Playgroud)

webpack passport.js webpack-dev-server

5
推荐指数
0
解决办法
655
查看次数

如何对Ant Design的表单getFieldDecorator()进行存根处理?

我正在尝试对表单进行简单的Jest快照测试,但是在运行测试时出现错误:

Uncaught [TypeError: getFieldDecorator(...) is not a function]
Run Code Online (Sandbox Code Playgroud)

我以为我可以为它创建一个存根getFieldDecorator并将其传递给道具,但这是行不通的。

这是测试:

  it('renders correctly initially', () => {

const testForm = {
  getFieldDecorator: jest.fn()
};

const wrapper = mount(
  <Router>
    <LoginForm form={testForm} />
  </Router>
);

expect(wrapper).toMatchSnapshot();
Run Code Online (Sandbox Code Playgroud)

});

这是我组件中的render()方法:

  render() {
const { form } = this.props;
const { getFieldDecorator } = form;

return (
  <Form onSubmit={this.handleSubmit} className="login-form">
    <FormItem>
      {getFieldDecorator('username', {
        rules: [{ required: true, message: 'Please enter your username!' }]
      })(
        <Input
          prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
          placeholder="Username" …
Run Code Online (Sandbox Code Playgroud)

reactjs antd

5
推荐指数
1
解决办法
822
查看次数

4
推荐指数
1
解决办法
7904
查看次数