繁体   English   中英

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

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

(这主要是关于如何实现它的问题)

我是新来的反应并尝试使用项目Hooks + Redux + Saga.

反应16.9

逻辑流程

* 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.

我的问题是实现该功能的最佳方式是什么:

  • 允许 STEP1 上的学生单击“ Next button (尚未保存任何内容),能够显示从下一页顶部的表单输入的字段

  • 然后只有在步骤 2 上按save后,才能保存步骤 1 和步骤 2 页面中的所有信息。

我想了解的主要是那种 state 管理。

提前致谢...

可能的想法:
1. 您将拥有一个名为Steps的组件,其中包含子组件Step1Step2

2. Steps组件将具有{currentStep,step1Data,step2Data}类型的 state

3. 根据currentStep的值,您将渲染Step1Step2组件,其中将显示 forms。

4. 当学生在Step1Step2填写表格时,数据将存储在Steps组件的 state 的step1Datastep2Data中。

5. 保存step1Datastep2Data后将保存在 redux(或服务器调用 haeppen)上。


谢谢

暂无
暂无

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

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