title: How to access store from componentDidMount()?
body: <p>This is a possible duplicate of </p>
  
  <p><a href="https://stackoverflow.com/questions/51982033/how-to-access-redux-store-from-within-reacts-componentdidmount">How to access redux-store from within react&#39;s componentDIdMount()</a></p>
  
  <p>I am finding that example to be confusing and more complicated than my implementation, so I'm going to risk asking again with a simpler code.</p>
  
  <p>I need to access my redux store from <code>componentDidMount()</code>. The following code renders the <code>&lt;h3&gt;</code> component but <code>console.log()</code>'s a <code>null</code> value:</p>
  
  <pre><code>class FinishedPaying extends Component {
  
    componentDidMount() {
      console.log(this.props.paymentID);
    }
    render() {
      return (
        &lt;div&gt;
          &lt;h3&gt;{this.props.paymentID}&lt;/h3&gt;
        &lt;/div&gt;
      );
    }
  }
  
  const mapStateToProps = (state, props) =&gt; {
    return {
      paymentID: state.paymentID
    };
  };
  
  const mapActionsToProps = (dispatch, props) =&gt; {
    return bindActionCreators(
      {
        updatePaymentID: updatePaymentID
      },
      dispatch
    );
  };
  
  export default connect(
    mapStateToProps,
    mapActionsToProps
  )(FinishedPaying);
  </code></pre>
  
  <p>reducer code:</p>
  
  <pre><code>import { UPDATE_PAYMENTID } from "../actions/paymentID-actions";
  
  export default function paymentIDReducer(state = "", { type, payload }) {
    switch (type) {
      case UPDATE_PAYMENTID:
        return payload.paymentID;
      default:
        return state;
    }
  }
  </code></pre>
  
  <p>actions code:</p>
  
  <pre><code>export const UPDATE_PAYMENTID = "paymentID:updatePaymentID";
  
  export function updatePaymentID(newPaymentID) {
    return {
      type: UPDATE_PAYMENTID,
      payload: {
        paymentID: newPaymentID
      }
    };
  }
  </code></pre>