question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support passing object as initial value

See original GitHub issue

Want to support object as initial value. Example:

  const [item, setItem] = useLocalStorage('name', {key: 'value'});

then item value should be an object also

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
lilasquaredcommented, Oct 31, 2021

This is my go to lib for lots of hooks. This one already supports complex objects via serialization. https://github.com/streamich/react-use/blob/master/src/useLocalStorage.ts

1reaction
fkraficommented, Oct 30, 2021

@dance2die, @lilasquared, @TheAifam5 , @SeanMcP , @VitorLuizC, @evgenymarkov,

can you please verify this PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting default value for TypeScript object passed as ...
Writing an interface, type or class for the parameter object improves legibility. type FullName = { firstName: string; /** @defaultValue 'Smith' */ lastName...
Read more >
Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
Read more >
Understanding Default Parameters in JavaScript
Any primitive value or object can be used as a default parameter value. In this section, you will see how this flexibility increases...
Read more >
Initialize Property Values - MATLAB & Simulink
Define properties with default values — MATLAB ® assigns the same initial value to the property of every instance. Set property values in...
Read more >
ref keyword - C# Reference
The storage location of the object is passed to the method as the value of the reference parameter. If you change the value...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found