This might be convoluted, so bear with me. I'm just beginning to learn React/Redux and managing state. I want to build a small app which does not use routing which looks like this:
Not unlike an install wizard.
A user would be prompted to answer a question on each page, then press a button to advance forward or backwards. At the end, the user will see the list of their answers.
I imagine the state would look something like this:
{
steps: [
{ prompt: 'Question in step 1', answer: null },
{ prompt: 'Question in step 2', answer: null },
{ prompt: 'Question in step 3', answer: null }
],
currentStepNumber: 0,
currentStepData: { prompt: 'Question in step 1', answer: null }
}
Advancing forwards/backwards should increment/decrement currentStepNumber
while currentStepData
should show, say steps[0]
. Additionally, responses should be saved while navigating.
Finally, all results should be visible on the final "page."
I'm really scratching my head how to do this without routing by simply passing props between components and containers.
The state object above is an attempt which looks like it might work but I feel like I'm not getting it.
Specific questions:
- How to show/hide components upon "navigation" without routes?
- Should the result container simply be hidden the entire time until the last step is reached?
- How do I design the state so that I know step N is the last step in the wizard and thus results container need to be displayed?