rehooks / local-storage

React hook which syncs localStorage[key] with the comp.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default value example in readme doesn't work

kokolem opened this issue · comments

Open your browser's developer tools to see the error on codesandbox.
It seems that default value doesn't work for objects, which is exactly what is shown as an example in readme.

commented

Looking into it!

The fix theoretically works, but the version (2.1.0) on NPM doesn't contain it. For some reason, it works on codesandbox, but please try to run it locally (just click on export to zip and run npm install) and you'll see it's not working. If you look into node_modules/@rehooks/local-storage, in src the fix is implemented, but not in lib (it's still 1.7 in there).

EDIT:
Looks like you forgot to run tsc --build before publishing to NPM.

commented

@iamsolankiamit you may have to republish with running npm run build first

I think this might be the problem:
As defined in package.json, npm run build will run tsc, not tsc --build.

@kokolem --build flag is only for incremental builds, build-mode-for-typescript.

@jharrilim I've republished it as 2.1.1.

I confirm that 2.1.1 contains the fix.