Skip to content

Default props can't be overridden by inline props #1123

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

Closed
tomdohnal opened this issue Aug 25, 2020 · 4 comments · Fixed by #1330
Closed

Default props can't be overridden by inline props #1123

tomdohnal opened this issue Aug 25, 2020 · 4 comments · Fixed by #1330
Labels
kind: bug Something isn't working
Milestone

Comments

@tomdohnal
Copy link

🐛 Bug Report

(A clear and concise description of what the bug is.)

To Reproduce

  1. Press the toggle button in the demo. The square animates OK.
  2. Press it again -> it animates "immediately". This is expected as we set default: { immediate: true } in the setStyle(...) call.
  3. Press it yet again -> it animates "immediately". This is NOT expected as we set immediate: false in the setStyle(...) call. It works as expected if we use default: { immediate: false } and override the "default" props. However, I think the default props should be overridden by setting specific props in the function calls.

See https://codesandbox.io/s/quirky-goodall-6z3og?file=/src/App.js

Expected behavior

The default props should be overridden by "inline" props.

Link to repro (highly encouraged)

https://codesandbox.io/s/quirky-goodall-6z3og?file=/src/App.js

Environment

  • react-spring v9.0.0.-rc3
  • react v16.12
@tomdohnal tomdohnal changed the title Default props can't be overridden Default props can't be overridden by inline props Aug 25, 2020
@lilpolymath
Copy link

lilpolymath commented Aug 26, 2020

Hi @tomdohnal the issue is because there is no prop with the name default.

This works fine.

if (toggle) {
  setStyle({
  transform: "translateX(0px)",
  immediate: true
  });
} 
else {
  setStyle({
  transform: "translateX(200px)",
  immediate: false
  });
}

@tomdohnal
Copy link
Author

I'm using the v9 (9.0.0.-rc3) version of the library which introduces the concept of default props.
https://aleclarson.github.io/react-spring/v9/#Default-props

@lilpolymath
Copy link

Ohh alright, my bad. I forgot you mentioned the environment you were running on.

But won't toggling the state of the default prop defeat the purpose of setting it as default?

@tomdohnal
Copy link
Author

Yeah, you probably wouldn't use it like that in a real-life scenario :)
However, the demo shows that if you set the default props within an imperative setStyle call and then try to override these default props in another setStyle call, it does NOT override them

@aleclarson aleclarson added kind: bug Something isn't working v9 labels Aug 26, 2020
@aleclarson aleclarson added this to the v9.0.0-rc.4 milestone Aug 26, 2020
@joshuaellis joshuaellis modified the milestones: v9.0.0-rc.4, v9.0.0 Mar 18, 2021
@joshuaellis joshuaellis linked a pull request Mar 18, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants