Skip to content

Instantly share code, notes, and snippets.

@budiadiono
Created March 7, 2023 01:25
Show Gist options
  • Save budiadiono/60a062091e828c4bf57b11ae745d2d60 to your computer and use it in GitHub Desktop.
Save budiadiono/60a062091e828c4bf57b11ae745d2d60 to your computer and use it in GitHub Desktop.
{
"Redux Slice": {
"scope": "typescript",
"prefix": "rdxslc",
"body": [
"import { createSlice, PayloadAction } from '@reduxjs/toolkit';",
"",
"export interface ${1:${TM_FILENAME_BASE/(.*)(\\.slice$)/${1:/pascalcase}/g}}State {",
"\t$0",
"}",
"",
"const initialState: ${1}State = {}",
"",
"export const ${2:${TM_FILENAME_BASE/(.*)(\\.slice$)/${1:/camelcase}/g}}Slice = createSlice({",
"\tname: '${2}',",
"\tinitialState,",
"\treducers:{},",
"})",
"",
"export const ${2}Reducer = ${2}Slice.reducer;",
"export const {} = ${2}Slice.actions;"
],
"description": "Create redux slice"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment