我正在尝试访问Users#indexinvitation_accepted_at
中我的对象中的设计属性。Users
设计属性在我的控制器方法以及 Rails 视图中返回。但是在 JSX 状态对象中传递给 React 时会丢失。
users_controller.rb
def index
@users = User.all
end
用户/index.html.erb
<%= react_component("User", props: {
users: @users
}) %>
<%= javascript_pack_tag 'user' %>
用户.jsx
// . . .
export default class User extends React.Component {
constructor(props) {
super(props);
this.state = { users: this.props.users };
}
// . . .
当我做 aconsole.log( this.state.users )
时,我得到了原始对象,但没有 Devise 属性。
这可能吗?还是我缺少步骤?