Skip to content
Home · Sonraki hedefe 100 XP
Son hareketler
Henüz bir öğrenme hareketi yok. İlk derse başlayın.

Software Engineering

Redux Toolkit: Selecting the scope of common state

Redux Toolkit helps organize shared status updates. Instead of moving each field to the global storage, it is necessary to determine which components need which data.

Bu derste neler var?

SIBERSALDIRI.COM · FOCUSED LESSON

What you will learn

  • To explain the relationship between situational need and Slice.
  • “Should the whole state be global?” To give a reasoned answer to the question.
  • Changing the example and comparing expected and observed behavior.

How it works and where the trust boundary lies

Native form fields can often remain in the component. Reducer logic must be clear and predictable; The apparent mutation syntax written with Redux Toolkit's Immer support is not permission to modify the actual repository uncontrolled. Evaluate the threats of writing secret tokens to persistent browser storage. Cache life of server data and interface preferences are different types of situations.

Redux Toolkit: Flow for selecting scope of common state: State need → Slice → Predictable update
Status need → Slice → Predictable update. The diagram shows the relationship; It does not replace the entire application.

Worked example

The following passage makes the concept visible. Evaluate samples containing commands or code in your own separate testing environment, not in the production system. Architectural diagrams and policy examples are not executable programs.

const counter = createSlice({
 name: 'counter', initialState: {value: 0},
 reducers: { increment(state) { state.value += 1; } }
});

Expected result and interpretation

Slice creates an action and reducer contract; Immer produces the update accordingly.

Compare the scenarios

StatusRecommended approachWhy?
Local form draftCan remain in componentNot every data needs to be global
API cacheDesign life timeServer data is different responsibility
secret in storageReduce persistenceDebug and storage may be exposed

Practice task

Justify where to keep status for a form outline, theme preference, and API list.

  1. Write down the expected outcome and acceptance condition before the action.
  2. Change a single variable; Record the observation and the medium you used.
  3. Evaluate the result with the comparison table above. Explain which assumption might be wrong if it does not fit.

Common mistake and how to correct it

Do not leave sensitive data visible in debug tools and persistent storage.

Test your understanding

Should all state be global?

Answer explained: No. Sharing requirement, life expectancy and liability limit are decisive.

Continue with related lessons

Technical reference

The explanation and examples of this course have been re-prepared for the academy. The link below is a technical reference to verify details of the technology or security approach used.

Bir adım daha ilerlediniz.

Dersi bitirdiyseniz tamamlandı olarak işaretleyin. İlerlemeniz bu cihazda saklanır.

Academy menu

Akademide ara

En az 2 karakter yazın.