File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,20 @@ The following example shows one way you can store the TreeList state - through a
146146
147147 async Task OnStateInitHandler(TreeListStateEventArgs<Employee> args)
148148 {
149- args.TreeListState = await LocalStorage.GetItem<TreeListState<Employee>>(UniqueStorageKey);
149+ try
150+ {
151+ var state = await LocalStorage.GetItem<TreeListState<Employee>>(UniqueStorageKey);
152+ if (state != null)
153+ {
154+ args.TreeListState = state;
155+ }
156+
157+ }
158+ catch (InvalidOperationException e)
159+ {
160+ // the JS Interop for the local storage cannot be used during pre-rendering
161+ // so the code above will throw. Once the app initializes, it will work fine
162+ }
150163 }
151164
152165 async Task OnStateChangedHandler(TreeListStateEventArgs<Employee> args)
You can’t perform that action at this time.
0 commit comments