• Home
  • Interactive Resume
  • Blog
    • Coding
    • Health & Fitness
    • Success & Lifestyle
  • Contact
  • About

BAOSS

  • Home
  • Interactive Resume
  • Blog
    • Coding
    • Health & Fitness
    • Success & Lifestyle
  • Contact
  • About

Week 8 Day 2 – FINAL Assessment and Starting FSP’s!

Home Coding Week 8 Day 2 – FINAL Assessment and Starting FSP’s!
Week 8 Day 2 – FINAL Assessment and Starting FSP’s!

Week 8 Day 2 – FINAL Assessment and Starting FSP’s!

Mar 15, 2017 | Posted by Bao Le | Coding |

Hey guys! I’m gonna make it quick since I really want to dive right back into my full-stack project (FSP).

As I said yesterday, I passed the final assessment with a perfect score, so that’s a LOAD off my back. It’s an absolute relief to not have assessments weighing on my shoulders anymore.

I’m going to spend the rest of the days for the next week and a half discussing my progress with my FSP. I’ll mostly going over what bugs I’ve found and what I did to go about debugging it. The bug of the day today was the way I had mapped my state to props in my session reducer while creating my front-end authentication form and links. Take a look at my state and session reducer code below:

{
  session: {
    currentUser: {
      id: 1,
      username: 'imbaoss'
    },
    errors: []
  }
}
const _nullUser = Object.freeze({
  currentUser: null,
  errors: []
});

const SessionReducer = (oldState = _nullUser, action) => {
  Object.freeze(oldState);

  switch (action.type) {
    case RECEIVE_CURRENT_USER:
      return merge({}, oldState, action.currentUser);
    case RECEIVE_ERRORS:
      return merge({}, oldState, {errors: action.errors});
    default:
      return oldState;
  }
};

What’s happening here is that my state has an object session with the key currentUser. In my SessionReducer,  where I RECEIVE_CURRENT_USER, I merge a new object, with my oldState,  and my action.currentUser. With the way action was passing in currentUser, I would be merging every prop of action.currentUser as a new key within my session object, as opposed to updating my currentUser key within my state to reflect the updated currentUser. Here’s what the code should look like:

const _nullUser = Object.freeze({
  currentUser: null,
  errors: []
});

const SessionReducer = (oldState = _nullUser, action) => {
  Object.freeze(oldState);

  switch (action.type) {
    case RECEIVE_CURRENT_USER:
      return merge({}, oldState, {currentUser: action.currentUser});
    case RECEIVE_ERRORS:
      return merge({}, oldState, {errors: action.errors});
    default:
      return oldState;
  }
};

You’ll notice in here that I have action.currentUser set as a value to the key currentUser. When this gets merged, the new object has its session updated with the proper currentUser.

I actually had some help with figuring out what was going on with this bug. We first set a couple of our action creators to the window, and tested the result of those action creators. We noticed that the currentUser key wasn’t being updated, but that we would have my user object’s keys within the session key, which meant that I was passing a user as intended, but not into currentUser as needed. That was when we started to move forward in the Redux cycle since we know that the actions worked correctly. Logically, the reducers was next in the cycle, and after some debugging, we found that I wasn’t merging my currentUser correctly.

That’s pretty much it! If you guys have any questions about the bug, I’d be more than happy to explain it some more. Talk to you guys tomorrow!

0
Share

About Bao Le

Web Developer at Dropbox. Reach out, I'd love to connect!

Latest Posts

From Bootcamp to Dropbox: Part 2 – Success in the Program

From Bootcamp to Dropbox: Part 2 – Success in the Program

November 27, 2017

Before reading Part 2, make sure you’ve read Part 1!...

From Bootcamp to Dropbox: Part 1 – Application Process

From Bootcamp to Dropbox: Part 1 – Application Process

October 9, 2017

The Decision The decision to go into programming, without...

Signed with Dropbox!

Signed with Dropbox!

September 8, 2017

After a grueling 3 months or so, my job search has come to...

How I Overcome Rejection and Stay Motivated

How I Overcome Rejection and Stay Motivated

July 17, 2017

Having just had my first real rejection from a company I...

How I Overcome Imposter Syndrome Every Single Day

How I Overcome Imposter Syndrome Every Single Day

May 22, 2017

Before I really go into how I personally overcome imposter...

Future Googler

Future Googler

May 2, 2017

I’m finally “finished” with my interactive...

Introducing the Graduate Job Seeker Program

Introducing the Graduate Job Seeker Program

April 26, 2017

I almost forgot to blog today haha. Please expect not as...

Progress on Progress

Progress on Progress

April 25, 2017

The end of Week X Day X titles are here! And with it marks...

Week 13 Day 5 – Google Co-Working Meetup

Week 13 Day 5 – Google Co-Working Meetup

April 24, 2017

The Google meetup was absolutely dope. It was an incredible...

Week 13 Day 4 – Catching Up

Week 13 Day 4 – Catching Up

April 21, 2017

I think I have a pretty solid game plan of how to attack my...

Contact Us

We're currently offline. Send us an email and we'll get back to you, asap.

Send Message

Let’s Connect!

© 2025 · imbaoss.com

  • Facebook
  • Twitter
  • Instagram
  • LinkedIn
  • GitHub
Prev Next