GithubHelp home page GithubHelp logo

yc910920 / yog2-react-redux-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hefangshi/yog2-react-redux-demo

0.0 2.0 0.0 28 KB

yog2与react-redux结合demo

JavaScript 98.37% CSS 0.42% Smarty 1.21%

yog2-react-redux-demo's Introduction

yog2-react-redux-demo

react-redux examples 移植生成的适用于 YOG2的 react-redux demo

实现了 React 的前端编译与后端同构渲染

Usage

前置步骤包含启动 YOG2 服务端,可参考 YOG2文档

要求 YOG2 版本高于1.0.0,服务端 yog2-kernel 版本高于1.0.0

git clone https://github.com/hefangshi/yog2-react-redux-demo.git
cd yog2-react-redux-demo
cd client
npm i --production # 安装npm前端组件
cd ..
yog2 release debug # 发布至 YOG2 服务端

访问浏览器 http://127.0.0.1:8085 即可浏览发布结果

FAQ

Q: 是否可以在server目录中使用js后缀替代es后缀

A: 可以,在[email protected]之后,可以通过在fis-conf.js中添加 fis.enableES7() 在server 文件夹中启用js后缀文件支持 ES7 功能。

Q: 新项目如何使用 NPM / React

A: 仅需在原有的fis-conf.js中添加两句配置即可

// 按照 react-redux 的目录规范设置源代码目录
fis.match('/client/{actions,components,constants,containers,page,reducers,store}/**.{js,es,jsx,ts,tsx}', {
    parser: fis.plugin('typescript', {
        module: 1,
        target: 0
    }),
    isJsXLike: true,
    isMod: true
});

// 启用npm管理前端组件
fis.enableNPM({
    autoPack: true // 使用autoPack可以自动将依赖的npm组件打包合并
});

Q: 有些同构库如 isomorphic-fetch 无法使用,报加载错误

A: 由于 YOG2 框架的前后端同构策略是直接加载前端编译产出,而 isomorphic-fetch 库的前端代码在加载期就包含了对浏览器端的强依赖,因此无法使用,建议使用axios

yog2-react-redux-demo's People

Contributors

hefangshi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.