[英]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:我有多个流程:
book-an-appointment is part of flow 1 and 2, with slight differences:预约是流程 1 和流程 2 的一部分,但略有不同:
Question: Which approach is best practice in developing such screen in react?问题:哪种方法是在 React 中开发此类屏幕的最佳实践? options I thought about are:
我想到的选项是:
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.