May 10 2024
Versions
Updates to useLiveState
Hook
The useLiveState() Hook was updated to include a config object as a third parameter.
Some background on the useLiveState()
Hook:
If you are familiar with React’s useState()
hook, we have a similar hook called useLiveState()
that can be used to sync data realtime for specific state variables in your code.
Hook syntax:
The hook takes in 3 parameters:
UNIQUE_ID
-> unique id in string to be synced across the screensINITIAL_VALUE
-> initial value of the stateOPTIONS
(object)syncDuration
-> debounce duration in milliseconds to sync realtime (optional, default value 50ms)resetLiveState
-> Boolean to reset locatl state value on server side on initiatlize of hook (default:false
)
The hook returns a setter and getter:
value
-> current state value (similar to useState hook)setValue
-> function to be called to set next value (similar to useState hook)
Example:
Option to Enable DOM Change Detection in Comment Mode
By default, we skip Comment
DOM Change Detection
when users are in Comment Mode
to improve performance.
However, you can turn Comment
DOM Change Detection
back on with the changeDetectionInCommentMode
property.
This will make Comment's
reposition themselves if the DOM happens to change while in Comment Mode
.
Default: false
API Methods:
Option to Sort Order of Comments in Sidebar
By default, the Comments
in the Sidebar
are ordered in descending order of when they were last updated.
You can change this sorting order with the sort-data
property.
There are three options for sorting:
asc
- to show comments in descendending order of when they were last updateddesc
- to show comments in ascending order of when they were last updatednone
- to show comments in the sequence they were added
Was this page helpful?