简体   繁体   English

如何开发一个在多个流程中呈现相似/相同屏幕的屏幕

[英]how to develop a screen where this similar/same screen is presented in multiple flows

I am developing a website in React.我正在用 React 开发一个网站。

In this website I have a screen - lets call it "book-an-appointment"在这个网站上,我有一个屏幕——我们称之为“预约”

And I have multiple flows:我有多个流程:

  1. book an appointment for existing client现有客户预约
  2. book an appointment for non-existing client不存在的客户预约

book-an-appointment is part of flow 1 and 2, with slight differences:预约是流程 1 和流程 2 的一部分,但略有不同:

  • some buttons that are shown only in one of them一些按钮仅在其中一个中显示
  • "next" button that takes the user to a different screen将用户带到不同屏幕的“下一步”按钮
  • it affects differently on the funnels它对漏斗的影响不同
  • of course each one of them is in a different URL当然他们每个人都在不同的 URL
  • and more...和更多...

Question: Which approach is best practice in developing such screen in react?问题:哪种方法是在 React 中开发此类屏幕的最佳实践? options I thought about are:我想到的选项是:

  • Creating A single screen that shows the relevant buttons and actions according to the state根据 state 创建显示相关按钮和操作的单个屏幕
  • Duplicating the screen for each flow (because of the small differences in it)为每个流程复制屏幕(因为其中的细微差别)

I am quite new to react.我很新的反应。 tried to look for an answer here and in google but couldnt find my answer.试图在这里和谷歌中寻找答案,但找不到我的答案。

In that case I would just use one Parent component with ether two child components with the different flows.在那种情况下,我将只使用一个父组件和两个具有不同流程的子组件。 You can make one JSON object where conditionally you add specific keys and you can later check if the isExisting field exists for example what kind of booking it is and show a the existing user flow component.您可以制作一个 JSON object,其中有条件地添加特定键,您稍后可以检查 isExisting 字段是否存在,例如它是哪种预订,并显示现有的用户流组件。

You could do it like that or have one component that just conditionally hides fields depending on what type of booking it is.您可以那样做,或者有一个组件根据预订类型有条件地隐藏字段。 In this case you would use conditional rendering.在这种情况下,您将使用条件渲染。 See the article below for more info.有关详细信息,请参阅下面的文章。

https://reactjs.org/docs/conditional-rendering.html#inline-if-with-logical--operator https://reactjs.org/docs/conditional-rendering.html#inline-if-with-logical--operator

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

相关问题 在同一屏幕上处理多个平面列表 - Dealing With Multiple Flatlists on the same Screen 如何将多个表单(屏幕)数据发送到 React Native 中的同一个请求 - how to send the multiple form (screen) data to the same request in react native 如何根据屏幕尺寸允许多个列大小? - How to allow multiple column sizes depending on screen size? 我如何在屏幕上处理多个上下文 state? - how can i multiple context state handle in screen? state 中的多项更改不会改变屏幕 - Multiple changes in state are not altering the screen 如何重新渲染或多次调用屏幕反应原生 - how to rerender or call multiple times a screen react-native React Router V4:如何在同一个屏幕上渲染模态只改变url然后用那个url,能够重建整个屏幕 - React Router V4: How to render a modal in the same screen changing only the url and then with that url, be able to rebuild the whole screen 如何从导航位置识别屏幕。 React Native中的DrawerNavigation或StackNavigation - How to identify the screen from where navigated from. DrawerNavigation or StackNavigation in react native React Native:使用不同的参数渲染到同一个屏幕 - React Native: render to the same screen with diferent params 有没有办法让 go 返回不在同一个 stackNavigator 中的屏幕? - Is there a way to go back to a screen that's not in the same stackNavigator?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM