Move spring logic to styled-components #1310
Unanswered
hansalmeida
asked this question in
Support
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Considering the lib is using mainly hooks, therefore it must be declared inside a component.
Is there a way to declare the animations in a styled-component scope?
Consider the following examples.
We'd usually setup our spring in the component logic scope. What intrigues me is that the web relies on semantics, logic, and styling, so I'd like to couple the styles to the styled-components scope since that's where the lib makes its changes.
In here we have styling both at the top before the return and at the bottom outside the component scope.
I've played with the library for a while, then I've found components in the "Render-props api" section.
For example:
Considering that's a component I can create a styled-components version of this and pass its props by using
.attrs
like thisWhich allows me to move the props logic to the component scope, but I won't be able to pass a value like
children: <animated.span>{children}</animated.span>
in order to wrap the children in an animated layer so I could couple the spring and the animated element together, the IDE will only complain about that.So in order to make it work I still have to pass something like that inside the styled component
This solves that problem of moving the spring logic to the scope of the styles but I still need to pass an animated element inside that spring component, and if I want to style it I'd still have to make a second styled-component for that animated element.
Is there a possible way for putting that logic styling section altogether and separate it from the component business rules?
Beta Was this translation helpful? Give feedback.
All reactions