Files
supabase/apps/studio/hooks/misc/useChanged.ts
CharisandJoshen Lim e8a19faa03 feat: drop file to import data in Table Editor (#37888)
* feat: drop file to import data

In the Table Editor for an empty table, make the entire grid area a
dropzone so that files can be dropped onto the grid area for importing.
Dropping a file opens the SpreadsheetImport side panel with the dropped
file already loaded.

* refactor: drag and drop file import

Refactor logic into hooks and utility functions

* refactor: file drop import

Small changes caught in code review

* Opt to pass file through valtio store instead of event listener

* refactor: telemetry properties + cleaning up hook deps

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-08-13 11:32:06 -04:00

13 lines
233 B
TypeScript

import { useEffect, useRef } from 'react'
export function useChanged<T>(value: T): boolean {
const prev = useRef<T>()
const changed = prev.current !== value
useEffect(() => {
prev.current = value
})
return changed
}