小编cou*_*dev的帖子

Redux表单 - initialValues不用状态更新

我在使用redux-form设置初始表单字段值时遇到了一些问题.

我正在使用redux-form v6.0.0-rc.3并对v15.3.0做出反应.

所以这是我的问题,我有一个用户网格,当点击用户行时,我正在导航到编辑用户页面并在网址中包含用户ID.然后在编辑用户页面上,我抓住id并调用fetchUser(this.props.params.id),这是一个返回this.state.users的动作创建者.然后,我试图通过调用以下方式设置表单初始值:

function mapStateToProps(state) {
    return { initialValues:  state.users.user }
}
Run Code Online (Sandbox Code Playgroud)

根据我的理解,这应该将initialValues设置为state.users.user,并且每当更新此状态时,也应该更新initialValues.对我来说情况并非如此.InitialValues被设置为先前单击的用户行(即this.state.users.user的先前状态).所以我决定测试这个并向这个组件添加一个按钮,当它被点击时,我再次使用硬编码的用户ID调用fetchUser:

this.props.fetchUser('75e585aa-480b-496a-b852-82a541aa0ca3');

这是正确更新状态,但initialValues的值不会更改.更新状态时不会更新.我在旧版本的redux-form上测试了这个完全相同的过程,它按预期工作.

我在这里做错了什么,或者这是我正在使用的版本的问题.

用户编辑表格 -

class UsersShowForm extends Component {

    componentWillMount() {
        this.props.fetchUser(this.props.params.id);
    }

    onSubmit(props){
        console.log('submitting');
    }

    changeUser() {
        this.props.fetchUser('75e585aa-480b-496a-b852-82a541aa0ca3');
    }

    renderTextField(field) {
        return (
      <TextField 
        floatingLabelText={field.input.label}
        errorText={field.touched && field.error}
        fullWidth={true}
        {...field.input}
      />)
    }

    render() {
        const { handleSubmit, submitting, pristine } = this.props;

        return(

            <div>
                <form onSubmit={handleSubmit(this.onSubmit.bind(this))} className="mdl-cell mdl-cell--12-col">

                    <Field name="emailAddress" component={this.renderTextField} label="Email Address"/>

                    <Field name="firstName" component={this.renderTextField} label="First Name"/>

                    <Field name="lastName" component={this.renderTextField} label="Last Name"/>
                </form> …
Run Code Online (Sandbox Code Playgroud)

reactjs redux redux-form react-redux

19
推荐指数
2
解决办法
1万
查看次数

RSpec测试Devise Mailer

我是RSpec和TDD的新手,我在编写RSpec测试时遇到困难,以测试Devise是否真的在用户注册后发送确认电子邮件.我知道我的应用程序正在按预期工作,因为我已经在开发和生产中对功能进行了物理测试.但是,我仍然需要为此功能编写RSpec测试,我无法弄清楚如何通过RSpec测试发送确认电子邮件.

factories/user.rb

FactoryGirl.define do
  factory :user do
    name "Jack Sparrow"
    email { Faker::Internet.email }
    password "helloworld"
    password_confirmation "helloworld"
    confirmed_at Time.now
  end
end
Run Code Online (Sandbox Code Playgroud)

spec/models/user_spec.rb

require 'rails_helper'

RSpec.describe User, type: :model do

  describe "user sign up" do
    before do
      @user = FactoryGirl.create(:user)
    end

    it "should save a user" do
      expect(@user).to be_valid
    end

    it "should send the user an email" do
      expect(ActionMailer::Base.deliveries.count).to eq 1
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

为什么Devise在创建@user后没有发送确认电子邮件?我的测试返回ActionMailer :: Base.deliveries.count = 0.正如我所说的,我是RSpec和TDD的新手所以我在这里完全遗漏了什么?

ruby rspec ruby-on-rails devise factory-bot

9
推荐指数
1
解决办法
1812
查看次数

Extjs 6 - 现代工具包ui-mixins构建错误

我有一个带有两个包的Extjs 6工作区(一个用于经典,一个用于现代)和一个示例应用程序.使用相应的ui-mixins设计经典包组件没有问题,例如:@include extjs-panel-ui();. 但是,当我尝试使用相应的ui-mixin设置现代组件的样式时,我收到一个错误:

[ERR] unknown definition for mixin named panel-ui : 

[INF] Build error for ../../../build/temp/production/pra_kitchensink/slicer-temp/pra_kitchensink-example.scss
[ERR] Error: Sass compilation encountered 1 error(s)
[ERR] 
[ERR] BUILD FAILED
[ERR] com.sencha.exceptions.ExBuild: Sass compilation encountered 1 error(s)
[ERR]   at sun.reflect.DelegatingMe
[ERR] thodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERR] 
[ERR] Total time: 21 seconds
Run Code Online (Sandbox Code Playgroud)

我试图在现代工具包中设置一个面板,以便我使用 @include panel-ui();

有谁知道为什么我能够将ui-mixins用于经典组件,但是当我尝试将ui-mixins用于现代组件时,我遇到了构建错误?令人困惑的是,如果我运行sencha app watch modern,它会按预期工作和运行,但是当我运行sencha app watch或者sencha app build我得到上面的构建错误时.

extjs sencha-touch-2 sencha-cmd extjs6-classic extjs6-modern

6
推荐指数
1
解决办法
980
查看次数