简体   繁体   English

React node app - 在前端或后端存储属性被监视(项目被监视)更好?

[英]React node app - is it better to store property is watched (item is watched) in frontend or backend?

I have a watchlist, where user can add items to.我有一个监视列表,用户可以在其中添加项目。 I want to either show add button or string 'item is already on watchlist'.我想显示添加按钮或字符串“项目已在关注列表中”。 is it better to store that isWatched prop on frontend or backend?将 isWatched 道具存储在前端还是后端更好? on frontend: I already do fetch watchlist.在前端:我已经获取了关注列表。 I can put make it global using for example context, then I could have an array of id's of watched items in my global store and pass it to components that checks 'isWatched'.我可以使用例如上下文将其设为全局,然后我可以在我的全局存储中拥有一组已监视项目的 id,并将其传递给检查“isWatched”的组件。 on backend: I could add it (isWatched prop) the to item in my product collection.在后端:我可以将它(isWatched prop)添加到我的产品集合中的项目。 then when user opens the product item, the prop isWatched is already there.然后当用户打开产品项目时,道具 isWatched 已经存在。 no fetching needed.无需获取。

What is good practise to/where store such properties?存储此类属性的良好做法是什么? Thank you谢谢

If you want the user to get the same results from a different browser - you should persist it on the backend side.如果您希望用户从不同的浏览器获得相同的结果 - 您应该将其保留在后端。 If not - then you can keep it on the FE side.如果没有 - 那么您可以将其保留在 FE 方面。

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

相关问题 删除监视文件夹时节点监视EPERM - Node watch EPERM when the watched folder is deleted 这是用Node后端和React前端来布局Web应用程序的好方法吗? - Is this a good way to layout a Web app with a Node backend and a React frontend? React前端和Node后端之间的身份验证 - Authentication between React frontend and Node backend 使用代码和框将前端(反应)连接到后端(节点) - Connecting frontend (react) to backend (node) using codesandbox 将数据从Node后端传输到React前端 - Transfer data from Node backend to React frontend 用于后端的节点JS Express和用于前端的React JS - Node JS Express for backend and React JS for frontend 如何跟踪使用Node.js和Mongodb观看的视频 - How to keep track of videos watched with Node.js and Mongodb 在Node.js中,是否可以判断监视文件的移动位置? - In Node.js, is it possible to tell where a watched file was moved to? 将 Nodejs 后端与 React 前端应用程序集成 - Integrate Nodejs Backend with React Frontend App 如何构建一个使用 React 构建的独立桌面应用程序,使用节点后端,并将前端和后端都包装在电子中作为桌面应用程序? - how to build a standalone desktop app built with react, using a node backend, and wrap both frontend and backend in electron as a desktop app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM