'id'通过action和reducer发送并注销'已删除',但实际上并未从firestore数据库中删除...
客户端列表:
class Clients extends Component {
handleClick = (id) => {
// e.preventDefault();
this.props.deleteClient(id)
}
render() {
const {clientList} = this.props
return (
<div className="container mt-5 text-center">
<h2>Here Are Your List of Clients...</h2>
{clientList && clientList.map(client => {
return(
<div key={client.id}>
<div className="my-2">
Client Name: {client.name} | Client Price: ${client.price}
<button className="ml-2" onClick={() => {this.handleClick(client.id)}}>x</button>
</div>
</div>
)
})}
<AddClient/>
</div>
)
}
}
const mapStateToProps = (state) => {
return {
clientList : state.firestore.ordered.clientList,
}
}
const mapDispatchToProps = (dispatch) => {
return{
deleteClient : (id) => dispatch(deleteClient(id))
}
}
export default compose(
connect(mapStateToProps, mapDispatchToProps),
firestoreConnect([
{collection: 'clientList', orderBy: 'name'},
])
)(Clients)
行动:
export const deleteClient = (id) => {
return(dispatch, getState, {getFirestore, getFirebase}) => {
const firestore = getFirestore();
firestore.collection("clientList").doc(id).delete().then(() => {
dispatch({type: 'DELETE CLIENT'})
}).catch((err) => {
dispatch({type: 'DELETE CLIENT ERROR', err})
});
}
}
如果您需要任何其他代码或信息,请与我们联系。 ps,登录控制台没有错误。
试试这个。 .doc(id)
因为id必须是字符串。
我认为你不需要qazxsw poi里面的qazxsw poi。
/
doc