如何从Root内部的函数访问另一个网址?

时间:2019-07-04 17:43:46

标签: reactjs react-router-dom

我的主Root.js中有一个函数

//Root.js
  deleteEmployee = employeeID => {
    let employeesList = this.state.employeesList;
    employeesList = employeesList.filter(person => person.id !== employeeID);
    this.setState({
      employeesList,
    });
  };
const ButtonRemoveEmployee = ({ id }) => {
  return (
    <AppContext.Consumer>
      {context => {
        console.log(this.props);
        return (
          <button
            className="employeePanel__list_btn btn-small waves-effect waves-light"
            onClick={() => context.deleteEmployee(id)}
          >
            Usuń pracownika
          </button>
        );
      }}
    </AppContext.Consumer>
  );
};

当我单击ButtonRemoveEmployee组件中的按钮时,一切正常。但是我想在从数组中删除项目后,使用函数deleteEmployee跟随其他URL。

0 个答案:

没有答案