Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sticky: active prop doesn't reset sticky state #2082

Closed
laukaichung opened this issue Sep 18, 2017 · 5 comments
Closed

Sticky: active prop doesn't reset sticky state #2082

laukaichung opened this issue Sep 18, 2017 · 5 comments
Assignees
Labels

Comments

@laukaichung
Copy link

laukaichung commented Sep 18, 2017

Steps

Create two sticky components , one on the left, and one on the right.
The right one should be inactive in default.
The left one has an onStick event to update the state to make the right sticky active.

Expected Result

The right sticky should become active after the left sticky fires onStick event.

Actual Result

The active prop doesn't seem to update on state change. The right sticky remains inactive.

Version

0.73.1

Testcase

https://codepen.io/anon/pen/xXwBxj (Invalid example, please read post 2)

@laukaichung laukaichung changed the title Active props doesn't update in Stick Component Active props doesn't update in Sticky Component Sep 18, 2017
@laukaichung laukaichung reopened this Sep 18, 2017
@layershifter
Copy link
Member

-this.state.rActive = bool
+this.setState({ rActive: bool})

Your component will never receive update in this case. Don't mutate React's state directly, use setState().

@laukaichung
Copy link
Author

laukaichung commented Sep 18, 2017

@layershifter ,thank you for the correction. I've made a simpler example to illustrate the problem:
This example has a button in the middle of Text placeholders to toggle the active state.
There's no issue when the sticky is inactive in default: https://codepen.io/anon/pen/RLWXpo

But when the sticky is active in default, and it's changed to inactive in the middle of sticking/scrolling,
it's still sticking: https://codepen.io/anon/pen/WZQVLa

@layershifter layershifter reopened this Sep 18, 2017
@layershifter layershifter self-assigned this Sep 18, 2017
@layershifter layershifter added bug and removed invalid labels Sep 18, 2017
@layershifter
Copy link
Member

We should call also this.setState({ sticky: false }) in componentWillReceiveProps(), this will disable Sticky styles.

@layershifter layershifter changed the title Active props doesn't update in Sticky Component Sticky: active prop doesn't reset sticky state Sep 18, 2017
@laukaichung
Copy link
Author

laukaichung commented Sep 18, 2017

Tried it, but componentWillReceiveProps() never gets called on the button click. https://codepen.io/anon/pen/RLWXpo

@layershifter
Copy link
Member

PR was opened #2083.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants