简体   繁体   English

用rails响应路由器服务器端渲染

[英]react router server side rendering with rails

I am using React Js with rails 5.0 我正在使用带有Rails 5.0的React Js

Important Gems are 重要的宝石是

gem 'rails', '~> 5.0.2'
gem 'react-rails'
gem 'react-router-rails' 
gem 'slim-rails'

my layout and page template is in slim and I am using coffee everywhere. 我的布局和页面模板很小,我到处都在喝咖啡。

I am facing lots of problem when I am using react router. 我在使用React Router时遇到很多问题。

List of questions are: 问题清单是:

  1. I want to get a clean approach like angular where I can use module + controller + views in react. 我想得到一个像angular这样的干净方法,可以在react中使用模块+控制器+视图。 Can be it possible? 有可能吗

  2. As now I am using react-router but the thing is that when it send request to the server so request comes to my action controller, action view and layout but does not load react components. 现在,我正在使用react-router,但事实是,当它向服务器发送请求时,请求就到达了我的动作控制器,动作视图和布局,但没有加载react组件。

  3. I am not able to use new packages like react-validation( https://www.npmjs.com/package/react-validation ). 我不能使用像react-validation( https://www.npmjs.com/package/react-validation )这样的新软件包。 How can I use react packages. 如何使用React软件包。

  4. In react routing I want to send request on server and then it loads components which is exist on that action view. 在反应路由中,我想在服务器上发送请求,然后加载该操作视图中存在的组件。

  5. Suggest me for the best approach of using react js + rails 建议我使用React JS + Rails的最佳方法

Let's start with the basics, and I apologize if it sounds too basic. 让我们从基础开始,如果听起来太基础,我深表歉意。

  • 'React' can be viewed as the Facebook JavaScript libraries, the set of JavaScript libraries put out by a community of React users, or the base design philosophy of nested component rendering and tag based caching. 可以将“ React”视为Facebook JavaScript库,React用户社区推出的JavaScript库集,或者视为嵌套组件渲染和基于标签的缓存的基本设计理念。
  • JavaScript is inherent to React libraries, but not to its philosophy. JavaScript是React库所固有的,但不是其哲学的本质。
  • React on Ruby can be viewed as copying the philosophy or of cross-compiling to or generating JavaScript, or possibly emulating JavaScript in Ruby. React on Ruby可以看作是复制哲学或交叉编译到或生成JavaScript,或可能在Ruby中模拟JavaScript。
  • React is inherently a 'View' component, with additional libraries use a component and JSX approach to other capabilities. React本质上是一个“视图”组件,其他库使用该组件和JSX方法来实现其他功能。 React-router is such a library. React-router就是这样一个库。
  • React is not Angular. React不是Angular。 Angular is more of an MVC framework. Angular更像是一个MVC框架。

You probably want to go down these paths: * Acquire the ability to code in JavaScript. 您可能想走这些路:*获得使用JavaScript进行编码的能力。 Running on the browser implies code in JavaScript. 在浏览器上运行暗含JavaScript代码。 * Use Rails only as a server side REST or GraphQL endpoint. *仅将Rails用作服务器端REST或GraphQL端点。 Alternately, use Rails to emit JavaScript and then use as REST or GraphQL endpoint. 或者,使用Rails发出JavaScript,然后用作REST或GraphQL端点。 * Non JavaScript code will not be able to use the latest JavaScript libraries. *非JavaScript代码将无法使用最新的JavaScript库。

It's good to think of the possibilities of what can be done, and this question suggests you are exploring. 最好考虑可以做什么,这个问题表明您正在探索。

暂无
暂无

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

相关问题 使用React-rails和Algolia进行服务器端渲染 - Server side rendering with React-rails and Algolia 使用rails + react-rails gem +反应路由器进行服务器渲染 - Server rendering with rails + react-rails gem + react router 使用服务器端渲染 (SSR) 将现有 Rails + React 应用程序转换为 React on Rails - Converting existing Rails + React application to React on Rails with Server Side Rendering (SSR) Rails 5 Redux React Server Side Rendering向客户端JavaScript警告“用新的…替换React渲染的子级…” - Rails 5 Redux React Server Side Rendering gives client side JavaScript warning 'Replacing React-rendered children with a new…' react-router-rails 服务器端渲染正确的组件,但绕过了父组件 - react-router-rails server side renders the correct component, but bypasses the parent component 以 React 形式验证服务器端 Rails model - Server side Rails model validation in a React form 在Ruby On Rails上使用PhantomJS进行动态页面的服务器端呈现 - Server side rendering for dynamic pages with PhantomJS on Ruby On Rails ReferenceError:未在 Ruby on Rails 服务器端渲染上使用 ReactJS 定义导航器 - ReferenceError: navigator is not defined using ReactJS on Ruby on Rails server side rendering react-bootstrap-如何使用服务器端渲染? - react-bootstrap - How to use server side rendering? Rails使用单个模板(Handlebars或Mustache)与Sammy.js进行客户端/服务器端呈现 - Rails Client side / Server side rendering using single template (handlebars or Mustache) with Sammy.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM