2018-11-20-local-saving-to-local-storage-on-keystroke.md
# saving to local storage on keystroke
Getting data
const data = convertToRaw(editorState.getCurrentContent());
Import convertToRaw
the same way you import convertFromRaw
then you can iterate that data do to various things
eg in bbc transcript model https://github.com/bbc/subtitalizer/blob/d102c233236b782011a4a94a21e6de13491abb45/src/components/TranscriptEditor.js#L105-L241
so, you need to get JSON of that content state, store that in localstorage, and use that to load into draft back.
So, basically
without the Immutable things
it will make it slow, can do debounce to improve perfroamce
this.debouncedRebuildTranscript = debounce(this.rebuildTranscript, 100);
import debounce from 'lodash.debounce';
https://lodash.com/docs/4.17.11 - debounce
This as you type, it postpones that until you do a 100ms pause in this example.
Laurian
Do it without, then test and see if you need it, but there is a lot of computation to do on a keystroke, and JS is single threaded