Skip to content

Experimental Babel plugin for React Native Unistyles to automatically inject `useStyles` hook whenever stylesheet is referenced

Notifications You must be signed in to change notification settings

justblender/babel-plugin-react-native-unistyles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-react-native-unistyles

Experimental Babel plugin for React Native Unistyles to automatically inject useStyles hook whenever stylesheet is referenced.

Before transformation:

import { View } from "react-native";
import { createStyleSheet } from "react-native-unistyles";

function App() {
  return <View style={styles.container} />;
}

const styles = createStyleSheet({
  container: {
    width: 100,
    height: 100,
  }
});

After transformation:

import { View } from "react-native";
import { createStyleSheet, useStyles as _useStyles } from "react-native-unistyles";

function App() {
  const { styles: _styles } = useStyles(_stylesheet);
  return <View style={_styles.container} />;
}

const _stylesheet = createStyleSheet({
  container: {
    width: 100,
    height: 100,
  }
});

Installation

pnpm install -D babel-plugin-react-native-unistyles

After installing, make sure to update your Babel configuration by adding "babel-plugin-react-native-unistyles" to the plugins array. This allows Babel to apply the plugin during compilation and transform your code as needed.

Contributing

Contributions are welcome. Please submit your pull requests or open issues to propose changes or report bugs.

About

Experimental Babel plugin for React Native Unistyles to automatically inject `useStyles` hook whenever stylesheet is referenced

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published