Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, {Component, PropTypes} from 'react';
- // import {bindActionCreators} from 'redux';
- import {connect} from 'react-redux';
- // import {load} from 'redux/modules/info';
- const tickerMapStateToProps =
- state => {
- console.log('mappingTickerstatetoprops');
- return {
- kali: state.kali
- };
- };
- //
- // const tickerMapDispatchToProps =
- // dispatch => { console.log(`Dispatching ${typeof dispatch}`); return ({}); };
- // @connect(
- // tickerMapStateToProps
- // // tickerMapDispatchToProps
- // )(Ticker) // eslint-disable-line arrow-body-style
- // @connect(state => ({ time: state.kali }))
- export class Ticker extends Component {
- static propTypes = {
- kali: PropTypes.object.isRequired,
- }
- componentWillReceiveProps(nextProps) {
- console.log(`Ticker got props: ${JSON.stringify(nextProps)}`);
- }
- render() {
- const { ticker, value } = this.props.kali;
- console.log(`Rendering Ticker props: ${ticker}: ${value}`);
- return (
- <div className="ticker">
- <b>THIS IS THE TICKER... {ticker}: {value} </b>
- </div>
- );
- }
- }
- const ConnectedTicker = connect(tickerMapStateToProps)(Ticker);
- export default ConnectedTicker;
- ====================
- Reducing @@redux/INIT
- Reducing @@redux/PROBE_UNKNOWN_ACTION_3.k.c.d.l.q.j.v.2.t.9
- Reducing @@redux/INIT
- Reducing @@router/LOCATION_CHANGE
- initial store is function
- tickerStore is function
- store is: {"routing":{"locationBeforeTransitions":{"pathname":"/","search":"","hash":"","state":null,"action":"POP","key":"mkaxyd","query":{},"$searchBase":{"search":"","searchBase":""}}},"reduxAsyncConnect":{"loaded":false},"auth":{"loaded":false},"form":{},"multireducer":{"counter1":{"count":0},"counter2":{"count":0},"counter3":{"count":0}},"info":{"loaded":false},"widgets":{"loaded":false,"editing":{},"saveError":{}},"kali":{"ticker":"GOOG","value":"-"}}
- Reducing redux-example/LOAD
- Reducing redux-example/auth/LOAD
- Reducing redux-example/LOAD_SUCCESS
- Reducing redux-example/auth/LOAD_SUCCESS
- Reducing reduxAsyncConnect/END_GLOBAL_LOAD
- mappingTickerstatetoprops <--- this is my mapStateToProps firing
- Rendering Ticker props: GOOG: - <--- This is the initial render of my component
- setInterval tick: {"type":"kali/STOCK_UPDATE","ticker":"GOOG","value":753.8116186731495} <--- a timer goes off, fires this action
- Reducing kali/STOCK_UPDATE <--- it gets reduced
- current state is {"ticker":"GOOG","value":"-"} <--- current state when the action fires
- new state is {"ticker":"GOOG","value":753.8116186731495} <--- new state after reducer runs
Advertisement
Add Comment
Please, Sign In to add comment