Cannot assign to ‘current’ because it is a read-only property

It’s simply a TypeScript error. Your syntax is problematic:

const unblockRef = useRef<() => void | null>(null);

This is interpreted as a function that returns either void or null.

So, you need to make sure it’s a function or null:

const unblockRef = useRef<(() => void) | null>(null);

Leave a Comment

File not found.