Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
ReactJs component does not get updated/rerendered when the store is updated

I have this component that shows list of education items added by the user where each time represents where he studied and for how long...etc:

class EducationItems extends Component {
  render() {
    const education = !!this.props.profile ? this.props.profile.education : [];
    return (
      <div>
        {!!education &&
          education.map((education_element_data, i) => {
            console.log(
              "๐Ÿš€ ~ file: EducationItems.js ~ line 26 ~ EducationItems ~ education.map ~ i",
              i
            );
            return (
              <EducationItem
                number={i}
                educationElementData={education_element_data}
              />
            );
          })}
      </div>
    );
  }
}

const mapStateToProps = (state) => ({
  profile: state.profile.profile,
});

const mapDispatchToProps = {};

export default connect(mapStateToProps, mapDispatchToProps)(EducationItems);

It is connected to the profile value in the store as you can see:

const mapStateToProps = (state) => ({
  profile: state.profile.profile,
});

When the user adds education, I get the new list of all education(s) he added and I try to updated in the UI. So in the reducer I have this:

profileReducer.js

const initialState = {
  profile: null,
};

   case ADD_EDUCATION:
      let updated_profile_with_new_education = state.profile;
      updated_profile_with_new_education.education =
        action.payload.updated_education;
     
      return {
        ...state,
        profile: updated_profile_with_new_education,
      };

The problem after the user adds an education successfully, the EducationItems component does not get rerendered.

It seems that it is not detecting the change in store.state.profile.education for some reason.

I thought that updating anything in store.state.profile would get it rerendered since it is connected to that value in the store.

Any idea what's going on?

about 4 years ago ยท Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!