* chore: rename APIs and Microservices to include "Backend" (#42515) * fix typo * fix typo * undo change * Corrected grammar mistake Corrected a grammar mistake by removing a comma. * change APIs and Microservices cert title * update title * Change APIs and Microservices certi title * Update translations.json * update title * feat(curriculum): rename apis and microservices cert * rename folder structure * rename certificate * rename learn Markdown * apis-and-microservices -> back-end-development-and-apis * update backend meta * update i18n langs and cypress test Co-authored-by: Shaun Hamilton <shauhami020@gmail.com> * fix: add development to front-end libraries (#42512) * fix: added-the-word-Development-to-front-end-libraries * fix/added-the-word-Development-to-front-end-libraries * fix/added-word-development-to-front-end-libraries-in-other-related-files * fix/added-the-word-Development-to-front-end-and-all-related-files * fix/removed-typos-from-last-commit-in-index.md * fix/reverted-changes-that-i-made-to-dependecies * fix/removed xvfg * fix/reverted changes that i made to package.json * remove unwanted changes * front-end-development-libraries changes * rename backend certSlug and README * update i18n folder names and keys * test: add legacy path redirect tests This uses serve.json from the client-config repo, since we currently use that in production * fix: create public dir before moving serve.json * fix: add missing script * refactor: collect redirect tests * test: convert to cy.location for stricter tests * rename certificate folder to 00-certificates * change crowdin config to recognise new certificates location * allow translations to be used Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com> * add forwards slashes to path redirects * fix cypress path tests again * plese cypress * fix: test different challenge Okay so I literally have no idea why this one particular challenge fails in Cypress Firefox ONLY. Tom and I paired and spun a full build instance and confirmed in Firefox the page loads and redirects as expected. Changing to another bootstrap challenge passes Cypress firefox locally. Absolutely boggled by this. AAAAAAAAAAAAAAA * fix: separate the test Okay apparently the test does not work unless we separate it into a different `it` statement. >:( >:( >:( >:( Co-authored-by: Sujal Gupta <55016909+heysujal@users.noreply.github.com> Co-authored-by: Noor Fakhry <65724923+NoorFakhry@users.noreply.github.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>
2.1 KiB
2.1 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
5a24c314108439a4d403614b | 創建一個 Redux Store | 6 | 301439 | create-a-redux-store |
--description--
Redux 是一個狀態管理框架,可以與包括 React 在內的許多不同的 Web 技術一起使用。
在 Redux 中,有一個狀態對象負責應用程序的整個狀態, 這意味着如果你有一個包含十個組件且每個組件都有自己的本地狀態的 React 項目,那麼這個項目的整個狀態將通過 Redux store
被定義爲單個狀態對象, 這是學習 Redux 時要理解的第一個重要原則:Redux store 是應用程序狀態的唯一真實來源。
這也意味着,如果應用程序想要更新狀態,只能通過 Redux store 執行, 單向數據流可以更輕鬆地對應用程序中的狀態進行監測管理。
--instructions--
Redux store
是一個保存和管理應用程序狀態的state
, 可以使用 Redux 對象中的 createStore()
來創建一個 redux store
, 此方法將 reducer
函數作爲必需參數, reducer
函數將在後面的挑戰中介紹。該函數已在代碼編輯器中爲你定義, 它只需將 state
作爲參數並返回一個 state
即可。
聲明一個 store
變量並把它分配給 createStore()
方法,然後把 reducer
作爲一個參數傳入即可。
注意: 編輯器中的代碼使用 ES6 默認參數語法將 state 的值初始化爲 5
, 如果你不熟悉默認參數,你可以參考ES6 全部課程,它裏面涵蓋了這個內容。
--hints--
Redux store 應當存在。
assert(typeof store.getState === 'function');
Redux store 的 state 的值應該爲 5。
assert(store.getState() === 5);
--seed--
--seed-contents--
const reducer = (state = 5) => {
return state;
}
// Redux methods are available from a Redux object
// For example: Redux.createStore()
// Define the store here:
--solutions--
const reducer = (state = 5) => {
return state;
}
const store = Redux.createStore(reducer);