question-mark
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.

Freezing of props passed to connected children

See original GitHub issue

preact: ^10.0.0-beta.1 storeon: ^0.8.3

Hi!

If I pass some props from the parent component to the connected (by the connect() function) child component, the props will be frozen there. Is it correct behavior?

You can see the example (https://codesandbox.io/s/exciting-nash-x8ur0?fontsize=14): checkbox updates a prop value in the Child component and doesn’t do it in the ChildConnected component.

And thank you for the lib! 🙂

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ahtohbi4commented, May 19, 2019

Sure.

  1. The first render (you open the page). The prop value, passed from parent component App, is on. To connect() function it comes with originProps and then mixed with props are coming from useSoreon() (line 10):

    Снимок экрана 2019-05-18 в 15 52 12
  2. Updating the prop value in the parent component App caused rerender child components, and to the function connect() now value is coming as off (originProps = { value: 'off' }). But the props came from useSoreon() contains the previous value value = 'on' and mixing with originProps (line 12) rewrite old value on:

    Снимок экрана 2019-05-18 в 15 52 37

So the children component wrapped with the function connect() will never update props, passed from parent.

0reactions
ahtohbi4commented, Jun 7, 2019

Now it perfectly works (https://codesandbox.io/s/exciting-nash-x8ur0?fontsize=14).

@hadeeb and @ai thank you for your work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problems with props passed to child component
I am having trouble passing props to a child component in my app. When I navigate to any subject link that which has...
Read more >
How to use Props in React - Robin Wieruch
As said, there is no way passing props from a child to a parent component. But you can always pass functions from parent...
Read more >
Why Kids Freeze Up During Homeschool Lesson - Shiller Math
One of the most common reasons kids freeze up or don't engage, is overwhelm. Even if it's a lesson you've gone over before....
Read more >
Ideas for Musical Games | Music Together
Try a game of “freeze dance”. Enjoy a game of "Freeze Dance" with one of the songs from your collection. · Play musical...
Read more >
Backstage Pass campers are busy designing and creating sets ...
Backstage Pass campers are busy designing and creating sets, costumes, props, staging and more for the Stars on Stage performance of Frozen this...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found