简体   繁体   English

如何在进程的不同阶段将数据临时存储在 redux 或 redux 传奇中

[英]how to temporarily store data in redux or redux saga on different phases of a process

(This is mostly a question on how to implement it) (这主要是关于如何实现它的问题)

I am new to react and trying to implement the logic below using the current configuration of the project Hooks + Redux + Saga.我是新来的反应并尝试使用项目Hooks + Redux + Saga.

React 16.9反应16.9

LOGIC FLOW逻辑流程

* The user is authenticated already.
* These two steps need to happen on the same URL but the UI displayed on different pages.
* No dependency allowed.

STEP 1:
-Each student has one form they need to fill out.
-The form has two fields: course and teacher. (value has to be typed)
-Once the two fields are filled out press button next.  

STEP2:
-The fields typed by the student will be displayed on the top of the page
-On this page, the student has a list of materials they can pick and add to the list to attend the course. 
-After choosing the material, the student can click Save
-Now when the student clicks Save, there is a page redirect to the home page.

My question is what would be the best way to implement the functionality:我的问题是实现该功能的最佳方式是什么:

  • that allows the student on STEP1 to click the Next button (Nothing is save yet), have the ability to show the fields entered from the form on the top of the next page允许 STEP1 上的学生单击“ Next button (尚未保存任何内容),能够显示从下一页顶部的表单输入的字段

  • then only after pressing save on STEP 2, be able to save all the informations from STEP 1 and STEP 2 pages.然后只有在步骤 2 上按save后,才能保存步骤 1 和步骤 2 页面中的所有信息。

It's mostly that kind of state management that i am trying to understand.我想了解的主要是那种 state 管理。

thanks in advance...提前致谢...

Possible Idea:可能的想法:
1. You will have a component named Steps which contain child Components Step1 and Step2 . 1. 您将拥有一个名为Steps的组件,其中包含子组件Step1Step2

2. The Steps component will have a state of type {currentStep,step1Data,step2Data} 2. Steps组件将具有{currentStep,step1Data,step2Data}类型的 state

3. Based on the value of currentStep you will render Step1 or Step2 component which will show the forms. 3. 根据currentStep的值,您将渲染Step1Step2组件,其中将显示 forms。

4. when student will fill form in Step1 or Step2 the data will be stored in step1Data or step2Data of state of Steps component. 4. 当学生在Step1Step2填写表格时,数据将存储在Steps组件的 state 的step1Datastep2Data中。

5. After save step1Data and step2Data will be saved on redux(or a server call haeppen). 5. 保存step1Datastep2Data后将保存在 redux(或服务器调用 haeppen)上。


Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM