Skip to content

Commit 5fc7871

Browse files
committed
Revert "Update all READMEs"
This reverts commit 27fe907.
1 parent 6ffb9e9 commit 5fc7871

File tree

3 files changed

+109
-736
lines changed

3 files changed

+109
-736
lines changed

packages/rtk-codemods/transforms/createReducerBuilder/README.md

Lines changed: 35 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -31,159 +31,38 @@ node ./bin/cli.js createReducerBuilder path/of/files/ or/some**/*glob.js
3131

3232
## <!--FIXTURES_CONTENT_START-->
3333

34-
---
35-
3634
<a id="basic-ts">**basic-ts**</a>
3735

3836
**Input** (<small>[basic-ts.input.ts](transforms\createReducerBuilder__testfixtures__\basic-ts.input.ts)</small>):
3937

4038
```ts
41-
import type { PayloadAction } from '@reduxjs/toolkit'
42-
import { createEntityAdapter, createReducer } from '@reduxjs/toolkit'
43-
44-
export interface Todo {
45-
id: string
46-
title: string
47-
}
48-
49-
export const todoAdapter = createEntityAdapter<Todo>()
50-
51-
const todoInitialState = todoAdapter.getInitialState()
52-
53-
export type TodoSliceState = typeof todoInitialState
54-
55-
const { addOne } = todoAdapter
56-
57-
createReducer(todoInitialState, {
58-
[todoAdded1a]: (state: TodoSliceState, action: PayloadAction<string>) => {
39+
createReducer(initialState, {
40+
[todoAdded]: (state: SliceState, action: PayloadAction<string>) => {
5941
// stuff
6042
},
61-
[todoAdded1b]: (state: TodoSliceState, action: PayloadAction<string>) =>
62-
action.payload,
63-
[todoAdded1c + 'test']: (
64-
state: TodoSliceState,
65-
action: PayloadAction<string>
66-
) => {
67-
// stuff
68-
},
69-
[todoAdded1d](state: TodoSliceState, action: PayloadAction<string>) {
70-
// stuff
71-
},
72-
[todoAdded1e]: function (
73-
state: TodoSliceState,
74-
action: PayloadAction<string>
75-
) {
76-
// stuff
77-
},
78-
todoAdded1f: (state: TodoSliceState, action: PayloadAction<string>) => {
79-
//stuff
80-
},
81-
[todoAdded1g]: addOne,
82-
todoAdded1h: todoAdapter.addOne
83-
})
43+
});
8444

85-
createReducer(todoInitialState, {
86-
[todoAdded2a]: (state: TodoSliceState, action: PayloadAction<string>) => {
45+
createReducer(initialState, {
46+
[todoAdded](state: SliceState, action: PayloadAction<string>) {
8747
// stuff
8848
},
89-
[todoAdded2b](state: TodoSliceState, action: PayloadAction<string>) {
90-
// stuff
91-
},
92-
[todoAdded2c]: function (
93-
state: TodoSliceState,
94-
action: PayloadAction<string>
95-
) {
96-
// stuff
97-
}
98-
})
49+
});
9950
```
10051

10152
**Output** (<small>[basic-ts.output.ts](transforms\createReducerBuilder__testfixtures__\basic-ts.output.ts)</small>):
10253

10354
```ts
104-
import type { PayloadAction } from '@reduxjs/toolkit'
105-
import { createEntityAdapter, createReducer } from '@reduxjs/toolkit'
106-
107-
export interface Todo {
108-
id: string
109-
title: string
110-
}
111-
112-
export const todoAdapter = createEntityAdapter<Todo>()
113-
114-
const todoInitialState = todoAdapter.getInitialState()
115-
116-
export type TodoSliceState = typeof todoInitialState
117-
118-
const { addOne } = todoAdapter
119-
120-
createReducer(todoInitialState, (builder) => {
121-
builder.addCase(
122-
todoAdded1a,
123-
(state: TodoSliceState, action: PayloadAction<string>) => {
124-
// stuff
125-
}
126-
)
127-
128-
builder.addCase(
129-
todoAdded1b,
130-
(state: TodoSliceState, action: PayloadAction<string>) => action.payload
131-
)
132-
133-
builder.addCase(
134-
todoAdded1c + 'test',
135-
(state: TodoSliceState, action: PayloadAction<string>) => {
136-
// stuff
137-
}
138-
)
139-
140-
builder.addCase(
141-
todoAdded1d,
142-
(state: TodoSliceState, action: PayloadAction<string>) => {
143-
// stuff
144-
}
145-
)
146-
147-
builder.addCase(
148-
todoAdded1e,
149-
(state: TodoSliceState, action: PayloadAction<string>) => {
150-
// stuff
151-
}
152-
)
153-
154-
builder.addCase(
155-
todoAdded1f,
156-
(state: TodoSliceState, action: PayloadAction<string>) => {
157-
//stuff
158-
}
159-
)
160-
161-
builder.addCase(todoAdded1g, addOne)
162-
builder.addCase(todoAdded1h, todoAdapter.addOne)
163-
})
164-
165-
createReducer(todoInitialState, (builder) => {
166-
builder.addCase(
167-
todoAdded2a,
168-
(state: TodoSliceState, action: PayloadAction<string>) => {
169-
// stuff
170-
}
171-
)
172-
173-
builder.addCase(
174-
todoAdded2b,
175-
(state: TodoSliceState, action: PayloadAction<string>) => {
176-
// stuff
177-
}
178-
)
179-
180-
builder.addCase(
181-
todoAdded2c,
182-
(state: TodoSliceState, action: PayloadAction<string>) => {
183-
// stuff
184-
}
185-
)
186-
})
55+
createReducer(initialState, (builder) => {
56+
builder.addCase(todoAdded, (state: SliceState, action: PayloadAction<string>) => {
57+
// stuff
58+
});
59+
});
60+
61+
createReducer(initialState, (builder) => {
62+
builder.addCase(todoAdded, (state: SliceState, action: PayloadAction<string>) => {
63+
// stuff
64+
});
65+
});
18766
```
18867

18968
---
@@ -193,15 +72,7 @@ createReducer(todoInitialState, (builder) => {
19372
**Input** (<small>[basic.input.js](transforms\createReducerBuilder__testfixtures__\basic.input.js)</small>):
19473

19574
```js
196-
import { createEntityAdapter, createReducer } from '@reduxjs/toolkit'
197-
198-
export const todoAdapter = createEntityAdapter()
199-
200-
const todoInitialState = todoAdapter.getInitialState()
201-
202-
const { addOne } = todoAdapter
203-
204-
createReducer(todoInitialState, {
75+
createReducer(initialState, {
20576
[todoAdded1a]: (state, action) => {
20677
// stuff
20778
},
@@ -218,11 +89,9 @@ createReducer(todoInitialState, {
21889
todoAdded1f: (state, action) => {
21990
//stuff
22091
},
221-
[todoAdded1g]: addOne,
222-
todoAdded1h: todoAdapter.addOne
223-
})
92+
});
22493

225-
createReducer(todoInitialState, {
94+
createReducer(initialState, {
22695
[todoAdded2a]: (state, action) => {
22796
// stuff
22897
},
@@ -231,61 +100,50 @@ createReducer(todoInitialState, {
231100
},
232101
[todoAdded2c]: function (state, action) {
233102
// stuff
234-
}
235-
})
103+
},
104+
});
236105
```
237106

238107
**Output** (<small>[basic.output.js](transforms\createReducerBuilder__testfixtures__\basic.output.js)</small>):
239108

240109
```js
241-
import { createEntityAdapter, createReducer } from '@reduxjs/toolkit'
242-
243-
export const todoAdapter = createEntityAdapter()
244-
245-
const todoInitialState = todoAdapter.getInitialState()
246-
247-
const { addOne } = todoAdapter
248-
249-
createReducer(todoInitialState, (builder) => {
110+
createReducer(initialState, (builder) => {
250111
builder.addCase(todoAdded1a, (state, action) => {
251112
// stuff
252-
})
113+
});
253114

254-
builder.addCase(todoAdded1b, (state, action) => action.payload)
115+
builder.addCase(todoAdded1b, (state, action) => action.payload);
255116

256117
builder.addCase(todoAdded1c + 'test', (state, action) => {
257118
// stuff
258-
})
119+
});
259120

260121
builder.addCase(todoAdded1d, (state, action) => {
261122
// stuff
262-
})
123+
});
263124

264125
builder.addCase(todoAdded1e, (state, action) => {
265126
// stuff
266-
})
127+
});
267128

268129
builder.addCase(todoAdded1f, (state, action) => {
269130
//stuff
270-
})
271-
272-
builder.addCase(todoAdded1g, addOne)
273-
builder.addCase(todoAdded1h, todoAdapter.addOne)
274-
})
131+
});
132+
});
275133

276-
createReducer(todoInitialState, (builder) => {
134+
createReducer(initialState, (builder) => {
277135
builder.addCase(todoAdded2a, (state, action) => {
278136
// stuff
279-
})
137+
});
280138

281139
builder.addCase(todoAdded2b, (state, action) => {
282140
// stuff
283-
})
141+
});
284142

285143
builder.addCase(todoAdded2c, (state, action) => {
286144
// stuff
287-
})
288-
})
145+
});
146+
});
289147
```
290148

291149
<!--FIXTURES_CONTENT_END-->

0 commit comments

Comments
 (0)