删除模型实例会触发LastPass保存密码吗?

时间:2018-07-20 15:44:22

标签: reactjs fetch

我正在使用Django Rest Framework和ReactJS。

当我单击IconButton删除用户实例时,我不明白为什么这段代码会启动LastPass保存密码小部件。

删除用户实例后,我正在调用this.props.onRequestMembers()重新呈现用户列表。

会员注册处

const mapDispatchToProps = (dispatch) => {
  return {
    onRequestMembers: () => dispatch(requestMembers())
  }
}


class MembersRegistry extends React.Component {

  componentDidMount() {
    this.props.onRequestMembers();
  };

handleClick = (e) => {
    e.preventDefault();
    const user = e.currentTarget.id;
    const conf = {
        method: "DELETE",
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json'
        },
      };
    fetch("http://localhost:8000/api/users/" + user, conf).then(response => 
    console.log(response)).then(() => {
        this.props.onRequestMembers();
    });
}

render(){

    ....
                <TableRow key={n.id}>
                    <TableCell>{n.first_name}</TableCell>
                    <TableCell>{n.last_name}</TableCell>
                    <TableCell>{n.email}</TableCell>
                    <TableCell>
                        <IconButton id={n.id} onClick={this.handleClick}>    
                            <DeleteIcon/>
                        </IconButton>
                    </TableCell>
                </TableRow>
        ....
    )
}

动作

export const requestMembers = () => (dispatch) => {
fetch('http://localhost:8000/api/users/')
.then(response => response.json())
.then(data => dispatch({ type: REQUEST_MEMBERS_SUCCESS, payload: data}))
.catch(error => dispatch({ type: REQUEST_MEMBERS_FAILED, payload: error}))
}

0 个答案:

没有答案