slib-native
v0.1.2
Published
Compnents
Readme
slib-native
A lightweight React Native component library written in TypeScript.
Easily reusable across iOS and Android projects, fully typed, and ready for production.
Installation
npm install slib-nativeor with Yarn:
yarn add slib-nativeUsage
import React from 'react';
import { SafeAreaView, Alert } from 'react-native';
import { Button } from 'slib-native';
export default function App() {
const handlePress = () => {
Alert.alert('Button pressed!');
};
return (
<SafeAreaView style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Button title="Click me" onPress={handlePress} />
</SafeAreaView>
);
}Adding New Components
- Create a new folder in
src/components/for your component, e.g.,MyComponent. - Add the component file (e.g.,
MyComponent.tsx) and any styles. - Export your component in
src/index.tsx:
export { default as MyComponent } from './components/MyComponent/MyComponent';- Run the build script to generate compiled files and TypeScript definitions:
npm run prepare- Commit your changes.
Publishing
The library uses GitHub Actions to automatically publish to npm on merges to main.
Manual publish is only required if needed:
npm run prepare
npm publish --access publicScripts
npm run prepare– Build the library (compile TypeScript and Babel).npm run build– Alias forbob build.npm run lint– Lint all files.npm run typecheck– TypeScript type check.npm run test– Run Jest tests.npm run clean– Remove thelibfolder.npm run release– Bump version and create Git tag.
Contributing
- Follow the existing code structure and patterns.
- Add TypeScript types for all components.
- Ensure your component works on both iOS and Android.
- Open a pull request against
main. GitHub Actions will handle build and npm publishing.
