React projects cannot save store? using redux, data

react projects cannot save store? using redux, data

index.js

ReactDOM.render(
  <Provider store={store}>
    <Router />
  </Provider>, document.getElementById("root"))
registerServiceWorker()

actions


export const SET_USER = "SET_USER"
export const LOGOUT = "LOGOUT"

export function setuser(login) {
  return {type: SET_USER, login}
}
export function logout(user) {
  return {type: LOGOUT, user}
}

reducers

import { combineReducers } from "redux"
import { SET_USER, LOGOUT } from "../actions"

function setuser(state = "1118", action) {
  switch(action.type) {
    case SET_USER:
      return action.login
    case LOGOUT:
      return ""
    default:
     return state
  }
}
const yg = combineReducers({
  setuser
})
export default yg

use:

class page1 extends Component {
  componentDidMount() {
    this.props.dispatch(setuser("555"))
    console.log(this.props.login)
    console.log("111")
  }
  render() {
    return (
        <Content style={{ padding: "0 10px" }}>
          <Breadcrumb style={{ margin: "8px 0", position: "relative" }} separator=">">
            <Breadcrumb.Item><Icon type="environment-o" /></Breadcrumb.Item>
            <Breadcrumb.Item>List</Breadcrumb.Item>
            <Breadcrumb.Item>App</Breadcrumb.Item>
            <div style={{ position: "absolute", right: "0px", top: "-6px"}}>
              <div style={{ float: "left", marginRight: "10px" }}>
                <Avatar style={{ backgroundColor: "-sharp87d068", marginRight: "5px", marginTop: "1px" }} icon="user" />
                <Popover placement="bottom" title="" content={content} trigger="click">
                  <Button type="dashed">user</Button>
                </Popover>
              </div>
              <div style={{ float: "left", marginRight: "10px" }}>
                <Avatar style={{ backgroundColor: "-sharp13c2c2", marginRight: "5px" }} icon="hdd" />
                <Button type="dashed">6+666</Button>
              </div>
              <div style={{ float: "left" }}>
                <Avatar style={{ backgroundColor: "-sharp2f54eb", marginRight: "5px" }} icon="calendar" />
                <Button type="dashed">year</Button>
              </div>
            </div>
          </Breadcrumb>
          <Layout style={{ padding: "24px 0", background: "-sharpfff" }}>
            <Sider width={200} style={{ background: "-sharpfff" }}>
              <Antdleftbar />
            </Sider>
            <Content style={{ padding: "0 24px", minHeight: 280, marginLeft: "50px" }}>
              <Antdtable />
            </Content>
          </Layout>
        </Content>
    )
  }
}
function select(state) {
  return {
    login: state.login
  }
}
export default connect(select)(page1)

the output result is
undefined
111

the previous project was effective in this way, but it didn"t work for half a year, but now it"s become like this. I don"t understand why
some places say that in order to solve the problem of React 0.13,
must be wrapped in a function with child
, but change to
{() = > < Router / >}
will show

.
React.Children.only expected to receive a single React element child.
 23 stack frames were collapsed.
./src/index.js
D:/software/workspace/bj_zbzq_ext/src/index.js:11
   8 | import yg from "./reducers"
   9 | let store = createStore(yg)
  10 | 
> 11 | ReactDOM.render(
  12 |   <Provider store={store}>
  13 |     { () => <Router /> }
  14 |   </Provider>, document.getElementById("root"))

I don"t understand why. I hope Daniel can help me to see what the problem is

.
Feb.26,2021

there is no login in your store directory structure


although dispatch is a Synchronize operation, you can't get a new state immediately after dispatch because of the asynchronous setState, in the connector. You can print out the this.props.login in render and you will know that it is actually modified. What about the creation code for


store? Login?
const store = createStore (
reducer
)

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b15fbc-29d26.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b15fbc-29d26.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?