Thank you for your interest in contributing to React Native Components! We greatly appreciate contributions from the community to make this library even better.
- Code of Conduct
- How to Contribute
- Development Environment Setup
- Project Structure
- Development Guidelines
- Pull Request Process
- Bug Reporting
- Feature Requests
- Documentation
- Testing
- Release Process
This project follows the Code of Conduct. By participating, you are expected to uphold this code of ethics.
There are several ways to contribute:
- Use GitHub Issues to report bugs
- Make sure the bug hasn't been reported before
- Provide detailed information and reproduction steps
- Open a GitHub Issue with the "feature request" label
- Explain the use case and benefits of the feature
- Discuss with maintainers before starting implementation
- Fork this repository
- Create a new branch for your changes
- Implement changes following the guidelines
- Create a Pull Request
- Fix typos or errors in documentation
- Add better usage examples
- Translate documentation to other languages
- Node.js (version 18 or newer)
- Bun (recommended package manager)
- React Native development environment
- Git
-
Fork and Clone Repository
git clone https://github.com/YOUR_USERNAME/react-native-components.git cd react-native-components -
Install Dependencies
bun install
-
Setup Development Environment
# Run example app for testing bun start # Or run documentation bun run docs:dev
-
Build Libraries
bun run build
react-native-components/
βββ apps/
β βββ docs/ # Astro documentation
β βββ example/ # Example React Native app
βββ libs/
β βββ rnc-theme/ # Main library
β βββ src/
β β βββ lib/
β β β βββ components/ # UI Components
β β β βββ context/ # React Contexts
β β β βββ hooks/ # Custom Hooks
β β β βββ themes/ # Theme definitions
β β β βββ types/ # TypeScript types
β β β βββ utils/ # Utility functions
β β βββ index.ts
β βββ package.json
βββ tools/
β βββ scripts/ # Build and utility scripts
β βββ templates/ # Template files
βββ package.json
-
TypeScript
- Use TypeScript for all code
- Define clear and comprehensive types
- Avoid using
any
-
Naming Conventions
- Components: PascalCase (
Button,Typography) - Files: kebab-case (
button.tsx,theme-provider.tsx) - Variables/Functions: camelCase (
handlePress,isVisible) - Constants: UPPER_SNAKE_CASE (
DEFAULT_THEME,MAX_WIDTH)
- Components: PascalCase (
-
Component Structure
// Import statements import React from 'react'; import { View } from 'react-native'; // Types interface ComponentProps { // props definition } // Component export const Component: React.FC<ComponentProps> = ({ // destructured props }) => { // hooks // handlers // render return ( <View> {/* JSX */} </View> ); }; // Default export export default Component;
-
Styling
- Use the existing theme system
- Avoid hardcoded values
- Use
useThemedStyleshook for styling
-
Accessibility
- Add proper accessibility props
- Use semantic elements
- Test with screen readers
-
Performance
- Use
React.memofor expensive components - Optimize re-renders with
useCallbackanduseMemo - Lazy load components if needed
- Use
-
Props Design
- Create intuitive and consistent props
- Use union types for variants
- Provide sensible defaults
-
Theme Integration
- All components must support theming
- Use existing theme tokens
- Create new theme tokens if needed
-
JSDoc Comments
/** * Button component with various styles and sizes * @param variant - Button style variant * @param size - Button size * @param onPress - Function called when button is pressed */
-
Component README
- Each component folder should have usage examples
- Document all props
- Provide working code examples
- Make sure your branch is up-to-date with
main - Run tests and ensure they all pass
- Check linting with
bun run lint - Build project with
bun run build
Use conventional commit format:
type(scope): description
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Formatting, missing semicolons, etcrefactor: Code refactoringtest: Adding or fixing testschore: Maintenance tasks
Example:
feat(button): add loading state support
Add loading prop to Button component that shows spinner
and disables interaction when true.
Closes #123
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Tests pass locally
- [ ] Added tests for new functionality
- [ ] Manual testing completed
## Screenshots (if applicable)
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] No breaking changes (or documented)- Maintainer will review your PR
- Respond to feedback constructively
- Make requested changes
- PR will be merged after approval
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Environment:**
- Device: [e.g. iPhone 12, Samsung Galaxy S21]
- OS: [e.g. iOS 15.0, Android 12]
- React Native version: [e.g. 0.72.0]
- Library version: [e.g. 1.0.0]
**Additional context**
Add any other context about the problem here.**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is.
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions.
**Additional context**
Add any other context or screenshots about the feature request here.# Run all tests
bun test
# Run tests in watch mode
bun test --watch
# Run tests with coverage
bun test --coverage-
Unit Tests
- Test component behavior
- Test utility functions
- Mock external dependencies
-
Integration Tests
- Test component interactions
- Test theme integration
- Test accessibility
-
Example Test
import React from 'react'; import { render, fireEvent } from '@testing-library/react-native'; import { Button } from '../Button'; describe('Button', () => { it('should call onPress when pressed', () => { const onPress = jest.fn(); const { getByText } = render( <Button onPress={onPress}>Test Button</Button> ); fireEvent.press(getByText('Test Button')); expect(onPress).toHaveBeenCalled(); }); });
We use Semantic Versioning:
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes (backward compatible)
- Update version in
package.json - Update
CHANGELOG.md - Create release tag
- Publish to npm
- Update documentation
- GitHub Issues: Bug reports and feature requests
- GitHub Discussions: General discussions
- Discord: Real-time chat (coming soon)
- Check existing issues and documentation
- Search in discussions
- Create new issue with appropriate template
By contributing, you agree that your contributions will be licensed under the same MIT License as this project.
Thank you for contributing! π
Every contribution, no matter how small, means a lot to the React Native community. Let's build an amazing library together!