freeCodeCamp/curriculum/challenges/italian/03-front-end-libraries/redux/get-state-from-the-redux-st...

1.2 KiB

id title challengeType forumTopicId dashedName
5a24c314108439a4d403614c Ottenere lo stato dallo store di Redux 6 301443 get-state-from-the-redux-store

--description--

L'oggetto store di Redux fornisce diversi metodi che consentono di interagire con esso. Ad esempio, è possibile recuperare lo state attuale contenuto nell'oggetto store di Redux con il metodo getState().

--instructions--

Il codice della sfida precedente viene riscritto più concisamente nell'editor di codice. Usa store.getState() per recuperare lo state dallo store, e assegnarlo a una nuova variabile currentState.

--hints--

Lo store di Redux dovrebbe avere un valore di 5 come stato iniziale.

assert(store.getState() === 5);

Una variabile currentState dovrebbe esistere e dovrebbe esserle assegnato lo stato corrente dello store di Redux.

(getUserInput) =>
  assert(
    currentState === 5 && getUserInput('index').includes('store.getState()')
  );

--seed--

--seed-contents--

const store = Redux.createStore(
  (state = 5) => state
);

// Change code below this line

--solutions--

const store = Redux.createStore(
  (state = 5) => state
);

// Change code below this line
const currentState = store.getState();