weixin_33724659 2016-08-09 23:48 采纳率: 0%
浏览 37

在多页网站上做出反应

I created a React App on a multi page website, but I don't know how to integrate it on our website.

Explanation of the problem

  1. The user load the website "/" (no react code is involved at the first loading)

  2. The user click on a link "/appReact"

  3. The _"/appReact" page loads the page and the React app code

  4. The React app sends ajax requests to the server

  5. Finally the React app gets the data and render itself

The step 3 and 4 makes the loading very slow. The step 3 delay is caused by the multipage nature of the website. The step 4 delay is caused by the response of the server

Possible solutions

I can try many different solutions or combine them, but I'm not sure if is the right way to proceed.

Optimize the react app to makes the ajax loader faster

In my case I can do that but is not the real problem.

Load the React app when the user load the website ("/")

This could improve the step 4, but we carry on the React app all around the website.

Use react router in conjunction of the multipage website

I don't know if is possible to do that. React-router can handle the url to load different apps, but I don't know if is possible to do in a multi site page without affect the site.

A trick using jquery

I have this temptation to bind the click (step 2) and hide the content of the page to run the react app. This will simulate a Single Page Application, but is a patch. I would like something more reliable.

Any suggestion?

  • 写回答

1条回答 默认 最新

  • weixin_33670713 2016-10-01 23:51
    关注

    You could try React Habitat

    That way you can pass properties to your React App directly on page load and not need the additional ajax request.

    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧