Skip to content

Instantly share code, notes, and snippets.

@FuadBalashov
Last active June 25, 2018 15:45
Show Gist options
  • Save FuadBalashov/1568cca994eba9812fc5b4c5fce6b53b to your computer and use it in GitHub Desktop.
Save FuadBalashov/1568cca994eba9812fc5b4c5fce6b53b to your computer and use it in GitHub Desktop.
ExtendedStyleSheet Sans Styles

ExtendedStyleSheet Sans Styles

By replacing the code in api.js of React Native Extended Stylesheets, you can remove all styles from components. This is helpful for measuring the impact of styles on performance.

To make this change, you will have to replace the create function in react-native-extended-stylesheet/src/api.js in the node_modules of your project with the one included in this gist.

If your project uses inline styles or normal stylesheets this change will not affect those styles.

/**
* Extended StyleSheet API
*/
...
...
...
export default class EStyleSheet {
...
...
...
/**
* REPLACE ME!!!!
* Creates stylesheet that will be calculated after build
* @param {Object} obj
* @returns {Object}
*/
create(obj) {
// this replaces all styles with an empy object.
for (var key in obj) {
obj[key] = {}
}
const sheet = new Sheet(obj);
// todo: add options param to allow create dynamic stylesheets that should not be stored
this.sheets.push(sheet);
if (this.builded) {
sheet.calc(this.globalVars);
}
return sheet.getResult();
}
...
...
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment