cssinjs / jss

JSS is an authoring tool for CSS which uses JavaScript as a host language.
https://cssinjs.org
MIT License
7.06k stars 397 forks source link

will `sheet.update` recalculate styles for every call? #799

Open HenriBeck opened 5 years ago

HenriBeck commented 5 years ago

From @Rabinzon on July 3, 2018 18:45

we have a lot of styles like this, so I gonna use function-values

const getLabelStyle = _.memoize(isMobileOrTablet =>
  ({
      paddingRight: isMobileOrTablet ? 16 : 2,
      ...
  }));

What if I'll call sheets.update(data) for every render? will It recalculate styles for every update? Sorry If information about this exists in docs, but I didn't found.

Copied from original issue: cssinjs/react-jss#268

HenriBeck commented 5 years ago

From @kof on July 3, 2018 18:50

it will and function values in JSS are designed to be efficient to do hundreds of updates in each frame

http://cssinjs.org/function-values

http://cssinjs.org/js-api?v=v9.8.7#update-function-values http://cssinjs.org/json-api?v=v9.8.7#function-values

Those are 2 places where we should add this information, its really important and for some reason we didn't add it.

Please send a PR!