LoginSignup
2
1

More than 5 years have passed since last update.

mapstatetopropsの偉大さを知った話

Posted at

reduxを使っているときにstoreの中身を見てみるとstateがjson形式で並んでるだけでなくそれを管理する新たなキーが作られていて謎だった

調べてみるとmapstatetopropsの時に指定していたものであった。

const mapStateToProps = (state) => {
    const { imageUrl, text } =  state.employeeForm;
    return { imageUrl, text };
}

みたいな感じで。

こうするとemployeeFormというキーに対するヴァリューの中にimageUrlとtextの ハッシュが格納される様になる。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1