[英]Rails/ReactJs View not updating on Browser Refresh
Just recently, I have added Reactjs to my Rails application.就在最近,我将 Reactjs 添加到我的 Rails 应用程序中。 However, whenever I reload the same.jsx file, but with different content (ie
<h1>Hello<h1/>
to <h1> Hello again<h1/>
), the browser does not respond and update the view.但是,每当我重新加载 same.jsx 文件但内容不同(即
<h1>Hello<h1/>
到<h1> Hello again<h1/>
)时,浏览器不会响应并更新视图。 I have tried restarting the server and reloading the page.我试过重新启动服务器并重新加载页面。 I have also created a separate rails application, and I was able to recreate Furthermore,I have also pulled my partner's repositories to check if there were any file differences.
我还创建了一个单独的 rails 应用程序,并且能够重新创建 此外,我还提取了我合作伙伴的存储库以检查是否存在任何文件差异。 There were none.
没有。
However , when I pull his repo, my browser updates the content, but it doesn't update it anymore afterward when I edit a.jsx file.但是,当我提取他的 repo 时,我的浏览器更新了内容,但之后当我编辑 a.jsx 文件时它不再更新了。 It should also be noted that when I edit the content on a.jsx file, the view updates for him, but it doesn't update for me when reloading the page.
还应该注意的是,当我编辑 a.jsx 文件上的内容时,视图会为他更新,但在重新加载页面时不会为我更新。 Our files are the same, but only I have the problem.
我们的文件是一样的,但只有我有问题。 I have also toggled safe mode, but it didn't make a difference.
我也切换了安全模式,但没有什么区别。
I am using Webpacker with Yarn on Jetbrains' RubyMine with Windows 10. Here is a picture of what the problem is: The code vs the output我在 Jetbrains 的 RubyMine 上使用带有 Yarn 的 Webpacker Windows 10。这是问题所在的图片:代码与 output
After a great amount of trial and error, the problem was with the IDE and where it was retrieving its settings and files from.经过大量试验和错误后,问题出在 IDE 及其从中检索其设置和文件的位置。 I had a backup HDD that held old information on it such as my last projects contents.
我有一个备份硬盘,上面保存着旧信息,例如我上一个项目的内容。 This was wiped.
这个被擦掉了。
I also managed to find old IDE settings in my "../users/%your_name$/.Rubymine2018.1".我还在我的“../users/%your_name$/.Rubymine2018.1”中找到了旧的 IDE 设置。 All old RubyMine settings were removed.
所有旧的 RubyMine 设置都已删除。 I also reinstalled my IDE to give it yet another clean start.
我还重新安装了我的 IDE 以重新启动它。 As far as I can tell, this has worked.
据我所知,这已经奏效了。
A big thanks to everyone who helped me in the comments!非常感谢所有在评论中帮助过我的人!
I have been facing the same issue, and as I have tried to follow the guide provided previously I couldn't know where to start from.我一直面临同样的问题,因为我试图按照之前提供的指南进行操作,所以我不知道从哪里开始。
And what I had to do is to run npm run build
everytime I update my jsx in my component.我必须做的是每次更新组件中的 jsx 时运行
npm run build
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.