项目作者: lava-x

项目描述 :
NextJs with Bulma CSS Framework, Redux, Redux Saga, Selectors, Immutable setup
高级语言: JavaScript
项目地址: git://github.com/lava-x/next-bulma-with-redux-saga.git
创建时间: 2018-10-17T07:05:03Z
项目社区:https://github.com/lava-x/next-bulma-with-redux-saga

开源协议:

下载


NextJs Starter

A Starter project for nextJs with implementation react, redux, redux-saga, selectors, immutable and Bulma CSS framework.

Demo

https://codesandbox.io/s/github/louiskhenghao/next-bulma-with-redux-saga

How to run app

Run development build

  1. yarn
  2. yarn dev

Run production build with:

  1. yarn build
  2. yarn start

Export as static HTML files

  1. yarn build
  2. yarn export
  3. # To try on your local machine
  4. # note: you'll need to install https://github.com/zeit/serve
  5. cd out
  6. serve -p 8080

Folder structure

  1. /config
  2. - index.js
  3. /components
  4. - YourDumbComponent.js
  5. /containers
  6. - /YourSmartComponent
  7. - component.jsx
  8. - connector.jsx
  9. /pages
  10. - YourPage.js
  11. /screens
  12. - /YourScreenComponent
  13. - index.jsx
  14. - styles.jsx
  15. /store
  16. - YourStoreName
  17. - actions.js
  18. - reducers.js
  19. - saga.js
  20. - selectors.js
  21. index.js
  22. RootReducers.js
  23. RootSagas.js
  24. /styles
  25. - theme.scss
  26. - styles.scss
  • components folder is the place for Dumb Component, (Dumb components are also called ‘presentational’ components because their only responsibility is to present something to the DOM.)
  • containers folder is the place for Smart Component, (Smart components (or container components) on the other hand have a different responsibility. Because they have the burden of being smart, they are the ones that keep track of state and care about how the app works.)
  • pages folder is the place for pages to be served, by default nextJs will consume the js file as page route, (Example: there is a mypages.js file under pages, so to access this page i just go to http://localhost:3000/mypages)
  • screens folder is the place for pages component, each page component will have a component and its styles, the purpose to having these due to some people would love to seperate style and component in different files (This is optional)
  • store folder as the folder name, it is for redux store, we encourage developer to seperate their store to different module, and each module it should have
    • actions.js - Actions are payloads of information that send data from your application to your store. They are the only source of information for the store.
    • reducers.js - Reducers specify how the application’s state changes in response to actions sent to the store. Remember that actions only describe what happened, but don’t describe how the application’s state changes.
    • saga.js - Aims to make application side effects (i.e. asynchronous things like data fetching and impure things like accessing the browser cache) easier to manage, more efficient to execute, simple to test, and better at handling failures.
    • selectors.js - Selectors are functions that take Redux state as an argument and return some data to pass to the component.
  • store/RootReducers.js - Combine of reducers from redux store modules (Remember to import reducer to RootReducers when adding new store). “Please be caution for clashing store name.”
  • store/RootSagas.js - Combine of saga from redux store modules (Remember to import watcher function to RootSagas from your new store if you wants saga to keep an eye for your dispatched action)
  • styles/theme.scss - this is the place where we import bulma theme, you can choose to define what you need to use for your application
  • styles/styles.scss - this file is to define global styles for your application

References

For anyone who would like to have better understanding please refer to the reference below:

  • For anyone who would like to have a better understanding of Dumb component and Smart component please refer @thejasonfile/dumb-components-and-smart-components-e7b33a698d43">this link
  • For redux, please refer this link for introduction and example. In simple redux can be described in three fundamental principles: [Single source of truth], [State is read-only], [Changes are made with pure functions]
  • For selectors, please refer this link for better understanding or its github
  • For redux saga please refer github for examples and explanation.
  • For immutableJS please refer to official documentation