Autodesk / Autodesk/react-base-table

Invalid ref in NextJS

Aperta
#387 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
1.5k
Fork
170
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con l'esempio «Inline Editing» nel sito della documentazione e con l'implementazione personalizzata di EditableCell, concentrandoti su come viene passato il suo ref e su quando targetRef diventa disponibile. Riproduci l'esempio in un ambiente NextJS, quindi verifica che gli elementi delle celle possano essere modificati in modo affidabile senza che ref sia null durante il rendering iniziale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
next.js, react, typescript
Ambito
frontend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.