@reduxjs/toolkit#Draft TypeScript Examples
The following examples show how to use
@reduxjs/toolkit#Draft.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: sliceUtils.ts From console with GNU Affero General Public License v3.0 | 6 votes |
flipValidPageInState = (
state: Draft<ICreateTenant>,
pageName: string,
valid: boolean
) => {
let originValidPages = state.validPages;
if (valid) {
if (!originValidPages.includes(pageName)) {
originValidPages.push(pageName);
state.validPages = [...originValidPages];
}
} else {
const newSetOfPages = originValidPages.filter((elm) => elm !== pageName);
state.validPages = [...newSetOfPages];
}
}
Example #2
Source File: slice.ts From pintora with MIT License | 5 votes |
function syncPreviewPintoraConfig(state: Draft<State>, code: string) {
try {
const pintoraConfig = JSON.parse(code)
state.preview.pintoraConfig = pintoraConfig
} catch (error) {
console.warn('Error when parsing state.configEditor.code')
}
}