Files
freeCodeCamp/curriculum/challenges/chinese/03-front-end-libraries/redux/get-state-from-the-redux-store.chinese.md
Oliver Eyton-Williams 61460c8601 fix: insert blank line after ```
search and replace ```\n< with ```\n\n< to ensure there's an empty line
before closing tags
2020-08-16 04:45:20 +05:30

1.3 KiB
Raw Blame History

id, title, challengeType, isRequired, videoUrl, localeTitle
id title challengeType isRequired videoUrl localeTitle
5a24c314108439a4d403614c Get State from the Redux Store 6 false 从Redux商店获取状态

Description

Redux存储对象提供了几种允许您与之交互的方法。例如您可以使用getState()方法检索Redux存储对象中保存的当前state

Instructions

上一个挑战中的代码在代码编辑器中更简洁地重写。使用store.getState()store检索state ,并将其分配给新变量currentState

Tests

tests:
  - text: 对于初始状态redux存储的值应为5。
    testString: assert(store.getState()===5);
  - text: 应该存在一个变量<code>currentState</code> 并且应该为其分配Redux存储的当前状态。
    testString: getUserInput => assert(currentState === 5 && getUserInput('index').includes('store.getState()'));

Challenge Seed

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

// change code below this line

Solution

// solution required

/section>