Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
React Material-Table Freezes after column update in ToolBar component

To be able to add the headers dynamically using a React Select component, I overrode the ToolBar of MaterialTable. The override worked, but now when I select more than 3 checkboxes and try to update the columns in MaterialTable's datamanger, the app terminates/freezes. (The documentation of MaterialTable didn't help me much with the implementation, so I had to work through the code to update the columns. That's why I'm not sure if I'm doing this correctly. Furthermore this is only a rough first implementation.). I would appreciate any tips on this. Thanks in advance ^^

The following code is inside the overridden Material-Table ToolBar componente. I simply "copied" the implementation of Material-Table and pasted the React-Select component into the ToolBar render method.

 handleChange = (selected) => {
    let columns = this.props.dataManager.columns;

    for (let index in columns) {
      columns[index].hidden = false;
    }

    for (let index in selected) {
      let cIndex = columns.findIndex(object => {
        return object.title === selected[index].value;
      });

      if (cIndex !== -1) {
        columns[cIndex].hidden = true;
      }
    }

    this.setState({
      optionSelected: selected,
    });

    this.props.dataManager.setColumns(columns); //?
    this.props.onColumnsChanged(columns); //Is this correct?
  }

  renderSelectHeaders() {
    let columns = this.props.columns.map((columns) => ({label: columns.title, value: columns.title}))
    return(
      <span
        class="d-inline-block"
        data-toggle="popover"
        data-trigger="focus"
        data-content="Please selecet columns"
      >
        <ReactSelect
            options={columns}
            isMulti
            placeholder={"Selected Columns"}
            closeMenuOnSelect={false}
            hideSelectedOptions={false}
            components={{
              Option
            }}
            onChange={this.handleChange}
            allowSelectAll={true}
            value={this.state.optionSelected}
            className={"select"}
          />
      </span>);
  }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda