The react-native-best-practices skill curates essential guidelines and best practices for React Native development. By implementing these practices, developers can enhance app performance and maintainability, ultimately saving time and reducing bugs.
git clone https://github.com/callstackincubator/agent-skills.gitThe react-native-best-practices skill is designed to provide developers with a comprehensive set of guidelines and best practices for building high-quality React Native applications. This skill focuses on optimizing performance, improving code maintainability, and ensuring a smooth user experience. By leveraging this skill, developers can quickly access proven strategies that help streamline their development process. One of the key benefits of using the react-native-best-practices skill is the significant time savings it offers. Developers can avoid common pitfalls and reduce the time spent debugging issues by following established best practices. This skill empowers teams to produce cleaner, more efficient code, which leads to faster development cycles and a more robust final product. This skill is particularly beneficial for developers, product managers, and AI practitioners who are involved in mobile app development. It is suitable for both novice and experienced developers looking to enhance their React Native projects. For example, a team working on a cross-platform mobile application can implement these best practices to ensure consistent performance across both iOS and Android platforms. Implementation of this skill is straightforward, making it accessible for teams at various experience levels. By integrating this skill into AI-first workflows, developers can enhance their productivity and focus on delivering value to users. Whether you are building a new app or optimizing an existing one, the react-native-best-practices skill is an invaluable resource for achieving excellence in mobile development.
1. **Identify Key Areas**: Start by identifying the key areas of your React Native app that need optimization. This could be performance, maintainability, or scalability. 2. **Research Best Practices**: Research the best practices for the identified areas. Use reliable sources like the official React Native documentation, blogs, and community forums. 3. **Implement Best Practices**: Implement the best practices in your app. Start with the most critical areas and gradually move to less critical ones. 4. **Test and Iterate**: Test the changes thoroughly to ensure they have the desired effect. Iterate on the implementation based on the test results. 5. **Document and Share**: Document the best practices you have implemented and share them with your team. This ensures that everyone is on the same page and can contribute to maintaining the best practices.
Enhancing performance of cross-platform mobile applications by following optimized coding practices.
Improving code maintainability for large-scale projects through established guidelines and patterns.
Reducing debugging time by implementing best practices that minimize common pitfalls.
Streamlining onboarding for new developers in React Native teams with clear, actionable guidelines.
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/callstackincubator/agent-skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Provide a list of 5 essential React Native best practices for [SPECIFIC APP FEATURE] development. Include code examples for each practice. Focus on [PERFORMANCE/MAINTAINABILITY/SCALABILITY] to improve [APP NAME]
1. **Use PureComponent for Performance Optimization**: In React Native, using PureComponent can significantly improve performance by preventing unnecessary re-renders. For example, in the [APP NAME] app, we can optimize the ProfileScreen component by converting it to a PureComponent. This ensures that the component only re-renders when its props change, reducing the number of renders and improving performance.
```javascript
import React, { PureComponent } from 'react';
class ProfileScreen extends PureComponent {
render() {
return (
<View>
<Text>{this.props.user.name}</Text>
</View>
);
}
}
```
2. **Avoid Inline Functions and Variables**: Inline functions and variables can lead to performance issues and make the code harder to maintain. Instead, define functions and variables outside the render method. For instance, in the [APP NAME] app, we can refactor the inline function in the HomeScreen component to improve performance and maintainability.
```javascript
class HomeScreen extends Component {
// Define the function outside the render method
handlePress = () => {
// Function logic here
}
render() {
return (
<Button title="Press Me" onPress={this.handlePress} />
);
}
}
```
3. **Use FlatList for Long Lists**: When dealing with long lists in React Native, using FlatList instead of ScrollView can greatly enhance performance. FlatList only renders the items that are currently visible on the screen, reducing memory usage and improving performance. For example, in the [APP NAME] app, we can optimize the MessagesScreen component by converting it to a FlatList.
```javascript
class MessagesScreen extends Component {
render() {
return (
<FlatList
data={this.props.messages}
renderItem={({ item }) => <Message message={item} />}
keyExtractor={(item) => item.id}
/>
);
}
}
```
4. **Use PropTypes for Type Checking**: PropTypes can help catch bugs early by ensuring that the props passed to a component are of the correct type. In the [APP NAME] app, we can add PropTypes to the UserProfile component to improve code quality and maintainability.
```javascript
class UserProfile extends Component {
static propTypes = {
user: PropTypes.shape({
name: PropTypes.string.isRequired,
age: PropTypes.number.isRequired,
}).isRequired,
}
render() {
return (
<View>
<Text>{this.props.user.name}</Text>
<Text>{this.props.user.age}</Text>
</View>
);
}
}
```
5. **Use Navigation Best Practices**: Following navigation best practices can improve the user experience and make the app more maintainable. In the [APP NAME] app, we can use the React Navigation library to implement a stack navigator for the main app flow. This ensures that the navigation is predictable and easy to maintain.
```javascript
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Profile" component={ProfileScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
```We create engaging workshops for companies and private events centred around plants, flowers and all things botanical.
Orchestrate workloads with multi-cloud support, job scheduling, and integrated service discovery features.
Serverless MySQL database platform
Design, document, and generate code for APIs with interactive tools for developers.
Manage CI/CD processes efficiently with build configuration as code and multi-language support.
Enhance performance monitoring and root cause analysis with real-time distributed tracing.