Skip to content

GlossCell & DefinitionCell set state of another component when they are rendered #1939

@jmgrady

Description

@jmgrady

Describe the bug

The onChange method for GlossCell and DefinitionCell calls the onChange method of another component that is passed in as a prop.

To Reproduce

Steps to reproduce the behavior:

  1. Open a project
  2. Click on Review Entries
  3. Edit an entry
  4. Click the '+' to add a gloss
  5. Console displays the following warning:
Warning: Cannot update a component (`MTableEditRow`) while rendering a different component (`GlossList`). To locate the bad setState() call inside `GlossList`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render
    at GlossList (http://localhost:3000/static/js/src_components_Pronunciations_PronunciationsComponent_tsx-src_goals_ReviewEntries_ReviewEntri-d1c73d.chunk.js:2779:23)
    at div
    at http://localhost:3000/static/js/bundle.js:18405:66
    at Grid (http://localhost:3000/static/js/bundle.js:27537:87)
    at div
    at http://localhost:3000/static/js/bundle.js:18405:66
    at Grid (http://localhost:3000/static/js/bundle.js:27537:87)
    at AlignedList (http://localhost:3000/static/js/src_components_Pronunciations_PronunciationsComponent_tsx-src_goals_ReviewEntries_ReviewEntri-d1c73d.chunk.js:2411:22)
    at GlossCell (http://localhost:3000/static/js/src_components_Pronunciations_PronunciationsComponent_tsx-src_goals_ReviewEntries_ReviewEntri-d1c73d.chunk.js:2730:80)
    at editComponent
    at td
    at http://localhost:3000/static/js/bundle.js:18405:66
    at TableCell (http://localhost:3000/static/js/vendors-node_modules_microsoft_signalr_dist_esm_HubConnectionBuilder_js-node_modules_mui_icon-cadf9b.chunk.js:30502:83)
    at tr
    at http://localhost:3000/static/js/bundle.js:18405:66
    at TableRow (http://localhost:3000/static/js/vendors-node_modules_microsoft_signalr_dist_esm_HubConnectionBuilder_js-node_modules_mui_icon-cadf9b.chunk.js:31841:82)
    at MTableEditRow (http://localhost:3000/static/js/vendors-node_modules_material-table_core_dist_index_js-node_modules_mui_icons-material_ArrowU-801ebe.chunk.js:10774:39)
    at MTableWithRefEditRow
...

Expected behavior

No warning in the console.

Environment:

  • OS: Ubuntu 22.04
  • Browser Version: Brave Version 1.48.171 Chromium: 110.0.5481.177 (Official Build) (64-bit)](https://brave.com/latest/)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions