You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ok, this is cool. Now I'm curious if you used a development or production mode … or to rephrase: If I want to provide cacheable CSS file for production how does it work? Do you identify dynamic styles and set them via the style attribute or inject a style tag?
Since #29 (and 0.2.0), we have simplified this. If you write:
letsomething;constX=styled.div`${something}`
Then the value of something will be locked to its initial value. There's no way around it, unless you call styled.divinside a render method like @mxstbr does above (you're effectively making a new component each time with whatever the current value of something is)
If you want something dynamic, though, just interpolate a function!
letsomething;constX=styled.div`${()=>something}`
Now every time X is re-rendered that function will be reevaluated and the current value of something will be injected. Easy!
Activity
mxstbr commentedon Sep 10, 2016
Yes, and you can also dynamically change it and it will actually change accordingly! 😱
No idea how this works, but it does, after one second left will be set to
50:nikgraf commentedon Sep 10, 2016
ok, this is cool. Now I'm curious if you used a development or production mode … or to rephrase: If I want to provide cacheable CSS file for production how does it work? Do you identify dynamic styles and set them via the style attribute or inject a style tag?
mxstbr commentedon Sep 10, 2016
This, I'm 99% sure. We use aphrodite under the hood, so there's no external CSS file at the moment. Not sure if we want to go down that route…
geelen commentedon Sep 27, 2016
Since #29 (and
0.2.0), we have simplified this. If you write:Then the value of
somethingwill be locked to its initial value. There's no way around it, unless you callstyled.divinside a render method like @mxstbr does above (you're effectively making a new component each time with whatever the current value ofsomethingis)If you want something dynamic, though, just interpolate a function!
Now every time
Xis re-rendered that function will be reevaluated and the current value ofsomethingwill be injected. Easy!nikgraf commentedon Sep 27, 2016
Thanks @geelen for the clarification!
Add operator mono for code (#23)