Files
freeCodeCamp/curriculum/challenges/english/03-front-end-libraries/redux/get-state-from-the-redux-store.md
Nicholas Carrigan (he/him) 31bdea63a2 chore(learn): audit front end libraries (#41179)
* chore(learn): audit bootstrap

* chore(learn): audit FE projects

* chore(learn): audit jQuery

* chore(learn): audit React

* chore(learn): audit react-redux

* chore(learn): audit redux

* chore(learn): audit sass

* fix: apply review suggestions

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>

* fix: apply non-suggestions

* chore: remove comments from code

Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
2021-02-25 10:19:24 -07:00

1.2 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5a24c314108439a4d403614c Get State from the Redux Store 6 301443 get-state-from-the-redux-store

--description--

The Redux store object provides several methods that allow you to interact with it. For example, you can retrieve the current state held in the Redux store object with the getState() method.

--instructions--

The code from the previous challenge is re-written more concisely in the code editor. Use store.getState() to retrieve the state from the store, and assign this to a new variable currentState.

--hints--

The Redux store should have a value of 5 for the initial state.

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

A variable currentState should exist and should be assigned the current state of the Redux store.

(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();