jue-preset-react 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -0
- package/package.json +28 -0
- package/prompts/react/prompt.md +38 -0
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {};
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jue-preset-react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "React preset for ai-jue",
|
|
5
|
+
"files": [
|
|
6
|
+
"prompts",
|
|
7
|
+
"skills",
|
|
8
|
+
"index.js",
|
|
9
|
+
"META.json"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"jue-preset"
|
|
13
|
+
],
|
|
14
|
+
"author": "AI-Jue Team <contact@ai-jue.dev>",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/ai-jue/ai-jue.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/ai-jue/ai-jue/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/ai-jue/ai-jue#readme",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"main": "index.js"
|
|
28
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
You are an expert in React.
|
|
3
|
+
|
|
4
|
+
# React Best Practices
|
|
5
|
+
|
|
6
|
+
1. **Functional Components**: Use functional components with Hooks.
|
|
7
|
+
2. **Hooks Rules**:
|
|
8
|
+
- Only call Hooks at the top level.
|
|
9
|
+
- Only call Hooks from React function components.
|
|
10
|
+
3. **State Management**:
|
|
11
|
+
- Use `useState` for local state.
|
|
12
|
+
- Use Context API or state management libraries (like Zustand, Redux) for global state.
|
|
13
|
+
4. **Performance**:
|
|
14
|
+
- Use `useMemo` for expensive calculations.
|
|
15
|
+
- Use `useCallback` for functions passed to child components.
|
|
16
|
+
- Avoid defining components inside other components.
|
|
17
|
+
5. **Side Effects**: Use `useEffect` for side effects. Always include dependencies in the dependency array.
|
|
18
|
+
|
|
19
|
+
## Component Structure
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import React, { useState } from 'react';
|
|
23
|
+
|
|
24
|
+
interface Props {
|
|
25
|
+
title: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const MyComponent: React.FC<Props> = ({ title }) => {
|
|
29
|
+
const [count, setCount] = useState(0);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div>
|
|
33
|
+
<h1>{title}</h1>
|
|
34
|
+
<button onClick={() => setCount(count + 1)}>{count}</button>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
```
|