简体   繁体   English

反应中不同内容模态窗口的最佳性能

[英]Best performance for varying content modal windows in react

Background背景

I used react to develop my most recent app and I really enjoyed the framework.我使用 react 来开发我最近的应用程序,我真的很喜欢这个框架。 However there is one thing that am i yet to understand and that is the implementation of varying content modal windows.然而,我还没有理解一件事,那就是不同内容模式窗口的实现。 When building content based web-app it seems to be something I stubble upon quite often so I would really like to get your thoughts on what is the best practice regarding the matter as I have been unsuccessful in finding it online在构建基于内容的网络应用程序时,这似乎是我经常遇到的问题,因此我真的很想了解您对有关此事的最佳实践的看法,因为我在网上找不到它

The problem问题

Let me present a sample problem in which it occurs.让我介绍一个发生这种情况的示例问题。 Saying we have a table with N rows.假设我们有一个包含 N 行的表格。 For each of these rows containing events i want to be able to open a modal window with detailed information about the event.对于包含事件的每一行,我希望能够打开一个包含有关事件的详细信息的模式窗口。

See picture看图在此处输入图片说明

Dilemma困境

Do we implement one Modal window with varying content dependant on something like redux state, or is it okay practice to implement one Modal/Row.我们是根据 redux state 之类的东西实现一个具有不同内容的 Modal 窗口,还是实现一个 Modal/Row 的做法是可以的。 What kind of performance side effects can we expect to see from the later of the approaches?我们可以期望从后面的方法中看到什么样的性能副作用? The more I think about it the more uncertain I get and therefore I would be very happy to get some clearance regarding the matter.我想得越多,我就越不确定,因此我很乐意就此事获得一些许可。

Best regards Albin最好的问候阿尔宾

If your detailed informations's modal has the same structure for each row, you can create one modal.如果您的详细信息的模态每行具有相同的结构,您可以创建一个模态。 You pass props from the row to the modal component and display them.您将道具从行传递到模态组件并显示它们。 For example, service name, price, status, user, location, ect ...例如,服务名称、价格、状态、用户、位置等...

But If your content will not be the same depending of event, yes you have to create differents modal.但是如果您的内容因事件而异,是的,您必须创建不同的模态。

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

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