Redux-React not connecting

Hello,

I am trying to connect my react to my redux, but the mapped stated is undefined in the props of my Presentational.

import React from "https://cdn.skypack.dev/react";
import ReactDOM from "https://cdn.skypack.dev/react-dom";
import { Provider, connect } from "https://cdn.skypack.dev/react-redux";
import { createStore } from "https://cdn.skypack.dev/redux";

const deepCopy = o => JSON.parse(JSON.stringify(o))

let initalState = {
  storedValue: null
};
const CHANGE_VALUE = "CHANGE_VALUE"
function reducer(state, action) {
  // Create a deep copy of the state
  let newState = deepCopy(state);
  switch (action.type) {
    case CHANGE_VALUE:
      newState.storedValue = action.value
    default:
      return deepCopy(newState);
  }
}
const mapDispatch = (dispatch) => {
  return {
    changeValue(value) {
      dispatch({
        type: CHANGE_VALUE,
        value: value
      })
    },
  }
}
const mapStateToProps = (store) => ({
  currentValue: store.currentValue
})
class ComplexLayerUI extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      currentValue: this.props.currentValue
    }
    this.handleInput = this.handleInput.bind(this)
  }
  handleInput(e) {
   this.state = {
     currentValue: e.target.value
   }
   this.props.changeValue(e.target.value)
  }
  render() {
    return (
        <input onChange={this.handleInput} value={this.props.currentValue}></input>
    );
  }
}
class Presentational extends React.Component {
  constructor(props) {
    super(props)
    console.log("Props:")
    console.log(props)
  }
  render() {
    return(
      <ComplexLayerUI/>
    )
  }
}
let store = createStore(reducer, deepCopy(initalState));
let Container = connect(mapStateToProps, mapDispatch)(Presentational);
class AppWrapper extends React.Component {
  constructor(props) {
    super(props)
  }
  render() {
    return (
      <Provider store={store}>
        <Container/>
      </Provider>
    );
  }
}
ReactDOM.render(<AppWrapper />, document.getElementById("root"));

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.