executeJS
Centipat
- Katılım
- 7 Ekim 2023
- Mesajlar
- 24
Daha fazla
- Sistem Özellikleri
- win11
- Cinsiyet
- Erkek
- Meslek
- Web Developer / Programmer
Aşağıdaki kodda Action. Payload nereden değer alıyor birkaç kaynaktan baktım anlayamadım açıklayıcı bir şekilde cevaplarınızı bekliyorum, kodun tam haline Redux'ın kendi sayfasından ulaşabilirsiniz.
Const initialstate = {
Value: 0,
}
Export const counterslice = createslice({
Name: 'counter',
İnitialstate,
Reducers: {
İncrement: (state) => {
// Redux toolkit allows us to write "mutating" Logic'in reducers. It.
// Doesn't actually mutate the state because it uses the ımmer library,
// Which detects changes to a "draft state" and produces a Brand New.
// İmmutable state based off those changes.
State. Value += 1
},
Decrement: (state) => {
State. Value -= 1
},
İncrementbyamount: (state, Action) => {
state. Value += Action. Payload
},
},
})
// Action creators are generated for each case reducer function.
Export const { increment, decrement, incrementbyamount } = counterslice. Actions.
Export default counterslice. Reducer.
Const initialstate = {
Value: 0,
}
Export const counterslice = createslice({
Name: 'counter',
İnitialstate,
Reducers: {
İncrement: (state) => {
// Redux toolkit allows us to write "mutating" Logic'in reducers. It.
// Doesn't actually mutate the state because it uses the ımmer library,
// Which detects changes to a "draft state" and produces a Brand New.
// İmmutable state based off those changes.
State. Value += 1
},
Decrement: (state) => {
State. Value -= 1
},
İncrementbyamount: (state, Action) => {
state. Value += Action. Payload
},
},
})
// Action creators are generated for each case reducer function.
Export const { increment, decrement, incrementbyamount } = counterslice. Actions.
Export default counterslice. Reducer.