Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[v.7.0.0] Component one update behind

See original GitHub issue

What is the current behavior?

After upgrading to v7.0.0-beta.0 our child components are one update behind the state unless we connect the parent component as well.

Here is a simple test component:

// @flow
import React from 'react'
import { connect } from 'react-redux'

type Props = {
  user: Object,
  organization: Object

 * @param {user} Object user from redux state
 * @param {organization} Object organization from redux state
export const TestComponent = ({ user, organization }: Props) => {
  console.log('First Name [Component]: ', user.firstName)
  return <div>{user.firstName}</div>

export const MSP = ({ user, organization }: Props) => {
  console.log('First Name [MSP]: ', user.firstName)
  return { user, organization }
export default connect(MSP)(TestComponent)

Here is the output using react-redux 6.0.1:

[DEBUG]: Initialize user module
First Name [MSP]:  Greg
First Name [Component]:  Greg
First Name [MSP]:  Gregg
First Name [Component]:  Gregg

here is the output using react-redux 7.0.0-beta.0

[DEBUG]: Initialize user module
First Name [MSP]:  Greg
First Name [Component]:  Greg
--- HERE I UPDATED STATE FROM Greg to Gregg ---
First Name [MSP]:  Gregg
First Name [MSP]:  Greggg
First Name [Component]:  Gregg

As you can see mapStateToProps requires the state to be modified a second time before updating the component to the previous state. It seems as though possibly the comparison check is not firing off?

Things I have tried:

  • Spreading the objects into a new object (new reference, comparison should be false and thus a rerender), this did not work.
  • Updating the functional component to a PureComponent and then Component, this did not work.
  • Removed all hooks from parent component, this did not work
  • Connecting parent component and mapStateToProps-ing the user object, THIS DID WORK

What is the expected behavior? Redux should do an equality check and notice that the state is different and update the component props accordingly.

React 16.8.5 React-Redux: 7.0.0-beta.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

navneet-gcommented, Apr 4, 2019

Awesome … from report to fix in 6 hours 😃

navneet-gcommented, Apr 4, 2019

Good news … I have a repro … I will upload it to code sandbox or create a repo to share soon. I have not debugged it yet to see what might be happening.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VMware vCenter Server 7.0 Update 3 Release Notes
From the Select a Product drop-down menu, select VC and from the Select a Version drop-down menu, select 7.0.3, and click Search. Attach...
Read more >
How to Upgrade from VMware vSphere ESXi 6.7 to 7.0
The workflow of upgrading ESXi 6.7 to ESXi 7.0, ESXi 7.0 Update 1, ESXi 7.0 Update 2, and other versions/builds of ESXi 7...
Read more >
Migrate From V6 to V7 - Simple React forms validation
Hi there,. React Hook Form focus on the following aspect on Version 7: (DX) Strict typed form. Reduce package size. Performance enhancements.
Read more >
Blazor @bind:after not working on .NET 7 RTM release #44957
App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft. ... If you still have issues after updating to 7.0.1 and following the steps described ...
Read more >
ASP.NET Core updates in .NET 7 Preview 7
NET Core in this update. ... package references to 7.0.0-preview.7.* . ... It's also now easier to setup binding for component parameters.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found