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

1.6 KiB

id title challengeType isRequired videoUrl localeTitle
5a24c314108439a4d403614c Get State from the Redux Store 6 false Obtenha o estado da loja Redux

Description

O objeto de armazenamento Redux fornece vários métodos que permitem interagir com ele. Por exemplo, você pode recuperar o state atual mantido no objeto de armazenamento Redux com o método getState() .

Instructions

O código do desafio anterior é reescrito de maneira mais concisa no editor de código. Use store.getState() para recuperar o state do store e atribua isso a uma nova variável currentState .

Tests

tests:
  - text: O armazenamento do redux deve ter um valor de 5 para o estado inicial.
    testString: 'assert(store.getState()===5, "The redux store should have a value of 5 for the initial state.");'
  - text: Uma variável <code>currentState</code> deve existir e deve ser atribuída ao estado atual do repositório do Redux.
    testString: 'getUserInput => assert(currentState === 5 && getUserInput("index").includes("store.getState()"), "A variable <code>currentState</code> should exist and should be assigned the current state of the Redux store.");'

Challenge Seed

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

// change code below this line

Solution

// solution required