React / useRef error - works in source observable notebook / fails when imported in another notebook

I have created a React function (using “@j-f1/react”) that makes use of “useRef()”

It works perfectly in the observablehq notebook where I have created it (see React - exporting function that uses useRef() / Ernesto Laval | Observable)

But if I import that function in another notebook, it will fail with “TypeError: Cannot read properties of null (reading ‘useRef’)”

See example at: React useRef issue when importing a function / Ernesto Laval | Observable

Has anybody experienced something similar? Any ideas on how to deal with this issue?

Thanks … (and Happy New Year!!)

1 Like