Coder Social home page Coder Social logo

redux-examples's Introduction

redux-examples

The purpose of this application is to document what the basic building blocks to connect Redux to a React.Js application. Most examples online use that silly ToDo app and it goes over my head all the time.

Install

npm install && npm start

Usage

The details on each topic will be in the /docs directory. The source code is functional once you run the app, but it's mainly for reference.

Basic structure

+-- dist
|   +-- index.html
+-- src
|   +-- reducers
|       +-- index.js
|   +-- app.js
+-- index.js

index.js

The main purpose of this file is to be the root of the application. Node is configured to look for this file as the starting point (you can change it when applicable). As it relates to React there are various key imports happening here:

  • react - the core React.Js library
  • react-dom - used to render the application to the div#app element in ./dist/index.html.
  • createStore (redux) - used to create a store and use an initial state of the application from the reducer.
  • applyMiddleware (redux; optional) - used to add additional tools (ie: redux-logger)
  • Provider (react-redux) - acts as the bridge between the Redux store and the application. All it does is provides access to the store, it doesn't interact with action creators or reducers directly.

src/app.js

The purpose of this file (in the context of this app) is to act as a Home Page for the user. No connection is made to Redux.

src/pages/functional-component.js

The purpose of this file is to demonstrate a functional React component connecting to the store.

  • connect (react-redux) - used as a way for this component to interact with the store, reducers, and action creators.

src/reducers/index.js

The purpose of this file is to update the store with a new application state. In the root file index.js the expected input for createStore() is a function that returns the state.

redux-examples's People

Contributors

fergatron 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.