diff --git a/components/treelist/state.md b/components/treelist/state.md index d4a1732901..3d551ae199 100644 --- a/components/treelist/state.md +++ b/components/treelist/state.md @@ -146,7 +146,20 @@ The following example shows one way you can store the TreeList state - through a async Task OnStateInitHandler(TreeListStateEventArgs args) { - args.TreeListState = await LocalStorage.GetItem>(UniqueStorageKey); + try + { + var state = await LocalStorage.GetItem>(UniqueStorageKey); + if (state != null) + { + args.TreeListState = state; + } + + } + catch (InvalidOperationException e) + { + // the JS Interop for the local storage cannot be used during pre-rendering + // so the code above will throw. Once the app initializes, it will work fine + } } async Task OnStateChangedHandler(TreeListStateEventArgs args)