Skip to main content

Add default / initial value to useSynced

  • Apr 9, 2020 5:45 AM UTC
  • 0 replies
  • 12 views

Forum|alt.badge.img+14

Similar to useState intial state.

Otherwise, there will always be boilerplate code of if value is null then value is initial value:

let [value, setValue, canSetValue] = useSynced('myGlobalConfigKey');
if (value == null) {
  value = 'initialValue';
}

Cheers,
Ronen Babayoff
Superblocks.at

This topic has been closed for replies.