Autodesk / Autodesk/react-base-table
Invalid ref in NextJS
- Vorherrschende Sprache
- TypeScript
- Sterne
- 1.5k
- Forks
- 170
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Is there a way to pass the ref to custom cell renders in NextJS environment?
The [Inline Editing](https://autodesk.github.io/react-base-table/examples/inline-editing) example in the documentation website doesn't work in NextJS because the ref provided to `EditableCell` is always null. I have tried various workarounds like loading the component dynamically and then using React.ForwardRef ([link](https://github.com/vercel/next.js/issues/4957)) but nothing seems to work. Even tried disabling SSR explicitly. The ref passed in is only valid after the first render cycle and it seems in the `EditableCell` class it tries to render with a null ref. You have some code protecting against this situation: `{editing && this.targetRef && (` but I'm wondering if there is a nicer or cleaner way to do this? I'm mainly looking for a way to edit the cell items.
Beitragsleitfaden
Rechercherichtung
Beginne mit dem Beispiel „Inline Editing“ auf der Dokumentationsseite und der benutzerdefinierten Implementierung von EditableCell. Konzentriere dich darauf, wie dessen ref übergeben wird und wann targetRef verfügbar wird. Reproduziere das Beispiel in einer NextJS-Umgebung und überprüfe anschließend, dass Zellenelemente zuverlässig bearbeitet werden können, ohne dass ref während des initialen Renderns null ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- next.js, react, typescript
- Bereich
- frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100