@idealyst/cli 1.0.24 → 1.0.26
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/README.md +109 -109
- package/dist/index.js +233 -36
- package/dist/types/generators/api.d.ts +2 -0
- package/dist/types/generators/index.d.ts +1 -0
- package/dist/types/generators/utils.d.ts +18 -1
- package/dist/types/types.d.ts +2 -1
- package/package.json +1 -1
- package/templates/api/README.md +207 -0
- package/templates/api/env.example +12 -0
- package/templates/api/package.json +49 -0
- package/templates/api/prisma/schema.prisma +21 -0
- package/templates/api/src/context.ts +23 -0
- package/templates/api/src/controllers/UserController.ts +102 -0
- package/templates/api/src/index.ts +14 -0
- package/templates/api/src/lib/controller.ts +90 -0
- package/templates/api/src/lib/middleware.ts +170 -0
- package/templates/api/src/middleware/auth.ts +75 -0
- package/templates/api/src/middleware/common.ts +103 -0
- package/templates/api/src/router/index.ts +130 -0
- package/templates/api/src/server.ts +50 -0
- package/templates/api/src/trpc.ts +28 -0
- package/templates/api/tsconfig.json +44 -0
- package/templates/native/.yarnrc.yml +18 -18
- package/templates/native/App.tsx +23 -23
- package/templates/native/README.md +85 -85
- package/templates/native/app.json +4 -4
- package/templates/native/babel.config.js +9 -9
- package/templates/native/index.js +5 -5
- package/templates/native/metro.config.js +27 -27
- package/templates/native/package.json +9 -9
- package/templates/native/src/App-with-trpc.tsx +72 -0
- package/templates/native/src/utils/trpc.ts +127 -0
- package/templates/native/tsconfig.json +29 -29
- package/templates/shared/README.md +108 -108
- package/templates/shared/package.json +39 -39
- package/templates/shared/tsconfig.json +24 -24
- package/templates/web/README.md +89 -89
- package/templates/web/index.html +12 -12
- package/templates/web/package.json +55 -51
- package/templates/web/src/App-with-trpc.tsx +80 -0
- package/templates/web/src/App.tsx +14 -14
- package/templates/web/src/main.tsx +24 -24
- package/templates/web/src/utils/trpc.ts +93 -0
- package/templates/web/tsconfig.json +26 -26
- package/templates/web/vite.config.ts +68 -68
- package/templates/workspace/.yarnrc.yml +25 -25
- package/templates/workspace/README.md +79 -79
- package/templates/workspace/package.json +24 -24
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
# {{projectName}}
|
|
2
|
-
|
|
3
|
-
{{description}}
|
|
4
|
-
|
|
5
|
-
## Getting Started
|
|
6
|
-
|
|
7
|
-
This is a React Native application built with the Idealyst Framework.
|
|
8
|
-
|
|
9
|
-
### Prerequisites
|
|
10
|
-
|
|
11
|
-
- Node.js 18+
|
|
12
|
-
- Yarn
|
|
13
|
-
- React Native development environment
|
|
14
|
-
- Android Studio (for Android development)
|
|
15
|
-
- Xcode (for iOS development)
|
|
16
|
-
|
|
17
|
-
### Installation
|
|
18
|
-
|
|
19
|
-
Install dependencies:
|
|
20
|
-
```bash
|
|
21
|
-
yarn install
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Running the App
|
|
25
|
-
|
|
26
|
-
Start the Metro bundler:
|
|
27
|
-
```bash
|
|
28
|
-
yarn start
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Run on Android:
|
|
32
|
-
```bash
|
|
33
|
-
yarn android
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Run on iOS:
|
|
37
|
-
```bash
|
|
38
|
-
yarn ios
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Project Structure
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
{{projectName}}/
|
|
45
|
-
├── src/
|
|
46
|
-
│ └── App.tsx # Main app component
|
|
47
|
-
├── android/ # Android-specific code
|
|
48
|
-
├── ios/ # iOS-specific code
|
|
49
|
-
├── babel.config.js # Babel configuration
|
|
50
|
-
├── metro.config.js # Metro configuration
|
|
51
|
-
└── tsconfig.json # TypeScript configuration
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Features
|
|
55
|
-
|
|
56
|
-
- **Idealyst Components**: Pre-built UI components
|
|
57
|
-
- **Idealyst Navigation**: Cross-platform navigation
|
|
58
|
-
- **Idealyst Theme**: Consistent theming system
|
|
59
|
-
- **TypeScript**: Full type safety
|
|
60
|
-
- **React Native 0.80.1**: Latest stable version
|
|
61
|
-
|
|
62
|
-
### Development
|
|
63
|
-
|
|
64
|
-
The app uses the Idealyst Framework for consistent UI and navigation across platforms.
|
|
65
|
-
|
|
66
|
-
Edit `src/App.tsx` to start building your application.
|
|
67
|
-
|
|
68
|
-
### Building for Production
|
|
69
|
-
|
|
70
|
-
Build Android APK:
|
|
71
|
-
```bash
|
|
72
|
-
yarn build:android
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Testing
|
|
76
|
-
|
|
77
|
-
Run tests:
|
|
78
|
-
```bash
|
|
79
|
-
yarn test
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Learn More
|
|
83
|
-
|
|
84
|
-
- [Idealyst Framework Documentation](https://github.com/your-username/idealyst-framework)
|
|
85
|
-
- [React Native Documentation](https://reactnative.dev/)
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
{{description}}
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
This is a React Native application built with the Idealyst Framework.
|
|
8
|
+
|
|
9
|
+
### Prerequisites
|
|
10
|
+
|
|
11
|
+
- Node.js 18+
|
|
12
|
+
- Yarn
|
|
13
|
+
- React Native development environment
|
|
14
|
+
- Android Studio (for Android development)
|
|
15
|
+
- Xcode (for iOS development)
|
|
16
|
+
|
|
17
|
+
### Installation
|
|
18
|
+
|
|
19
|
+
Install dependencies:
|
|
20
|
+
```bash
|
|
21
|
+
yarn install
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Running the App
|
|
25
|
+
|
|
26
|
+
Start the Metro bundler:
|
|
27
|
+
```bash
|
|
28
|
+
yarn start
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Run on Android:
|
|
32
|
+
```bash
|
|
33
|
+
yarn android
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Run on iOS:
|
|
37
|
+
```bash
|
|
38
|
+
yarn ios
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Project Structure
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
{{projectName}}/
|
|
45
|
+
├── src/
|
|
46
|
+
│ └── App.tsx # Main app component
|
|
47
|
+
├── android/ # Android-specific code
|
|
48
|
+
├── ios/ # iOS-specific code
|
|
49
|
+
├── babel.config.js # Babel configuration
|
|
50
|
+
├── metro.config.js # Metro configuration
|
|
51
|
+
└── tsconfig.json # TypeScript configuration
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Features
|
|
55
|
+
|
|
56
|
+
- **Idealyst Components**: Pre-built UI components
|
|
57
|
+
- **Idealyst Navigation**: Cross-platform navigation
|
|
58
|
+
- **Idealyst Theme**: Consistent theming system
|
|
59
|
+
- **TypeScript**: Full type safety
|
|
60
|
+
- **React Native 0.80.1**: Latest stable version
|
|
61
|
+
|
|
62
|
+
### Development
|
|
63
|
+
|
|
64
|
+
The app uses the Idealyst Framework for consistent UI and navigation across platforms.
|
|
65
|
+
|
|
66
|
+
Edit `src/App.tsx` to start building your application.
|
|
67
|
+
|
|
68
|
+
### Building for Production
|
|
69
|
+
|
|
70
|
+
Build Android APK:
|
|
71
|
+
```bash
|
|
72
|
+
yarn build:android
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Testing
|
|
76
|
+
|
|
77
|
+
Run tests:
|
|
78
|
+
```bash
|
|
79
|
+
yarn test
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Learn More
|
|
83
|
+
|
|
84
|
+
- [Idealyst Framework Documentation](https://github.com/your-username/idealyst-framework)
|
|
85
|
+
- [React Native Documentation](https://reactnative.dev/)
|
|
86
86
|
- [TypeScript Documentation](https://www.typescriptlang.org/)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "{{
|
|
3
|
-
"displayName": "{{
|
|
4
|
-
"react-native-version": "0.80.1"
|
|
1
|
+
{
|
|
2
|
+
"name": "{{appName}}",
|
|
3
|
+
"displayName": "{{appName}}",
|
|
4
|
+
"react-native-version": "0.80.1"
|
|
5
5
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
presets: ['module:@react-native/babel-preset'],
|
|
3
|
-
plugins: [
|
|
4
|
-
['react-native-unistyles/plugin', {
|
|
5
|
-
root: 'src',
|
|
6
|
-
autoProcessPaths: ['@idealyst/components', '@idealyst/navigation', '@idealyst/theme'],
|
|
7
|
-
}],
|
|
8
|
-
'react-native-reanimated/plugin',
|
|
9
|
-
],
|
|
1
|
+
module.exports = {
|
|
2
|
+
presets: ['module:@react-native/babel-preset'],
|
|
3
|
+
plugins: [
|
|
4
|
+
['react-native-unistyles/plugin', {
|
|
5
|
+
root: 'src',
|
|
6
|
+
autoProcessPaths: ['@idealyst/components', '@idealyst/navigation', '@idealyst/theme'],
|
|
7
|
+
}],
|
|
8
|
+
'react-native-reanimated/plugin',
|
|
9
|
+
],
|
|
10
10
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import '@idealyst/theme/unistyles';
|
|
2
|
-
|
|
3
|
-
import { AppRegistry } from 'react-native';
|
|
4
|
-
import App from './App';
|
|
5
|
-
|
|
1
|
+
import '@idealyst/theme/unistyles';
|
|
2
|
+
|
|
3
|
+
import { AppRegistry } from 'react-native';
|
|
4
|
+
import App from './App';
|
|
5
|
+
|
|
6
6
|
AppRegistry.registerComponent('{{projectName}}', () => App);
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const { wrapWithReanimatedMetroConfig } = require('react-native-reanimated/metro-config');
|
|
5
|
-
|
|
6
|
-
const config = {
|
|
7
|
-
projectRoot: __dirname,
|
|
8
|
-
watchFolders: [
|
|
9
|
-
// Add the workspace root to watch folders so Metro can watch workspace packages
|
|
10
|
-
path.resolve(__dirname, '..'),
|
|
11
|
-
],
|
|
12
|
-
resolver: {
|
|
13
|
-
nodeModulesPaths: [
|
|
14
|
-
path.resolve(__dirname, 'node_modules'),
|
|
15
|
-
// Add the workspace root node_modules
|
|
16
|
-
path.resolve(__dirname, '..', 'node_modules'),
|
|
17
|
-
],
|
|
18
|
-
// Important for Idealyst to use .native extensions for React Native (eg: @idealyst/components/src/Button/Button.native.tsx)
|
|
19
|
-
sourceExts: ['native.tsx', 'native.ts', 'tsx', 'ts', 'native.jsx', 'native.js', 'jsx', 'js', 'json'],
|
|
20
|
-
},
|
|
21
|
-
watcher: {
|
|
22
|
-
// When configuring custom components with .native extensions, make sure the watcher looks for them
|
|
23
|
-
additionalExts: ['native.tsx', 'native.ts', 'native.jsx', 'native.js'],
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
module.exports = wrapWithReanimatedMetroConfig(mergeConfig(getDefaultConfig(__dirname), config));
|
|
1
|
+
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const { wrapWithReanimatedMetroConfig } = require('react-native-reanimated/metro-config');
|
|
5
|
+
|
|
6
|
+
const config = {
|
|
7
|
+
projectRoot: __dirname,
|
|
8
|
+
watchFolders: [
|
|
9
|
+
// Add the workspace root to watch folders so Metro can watch workspace packages
|
|
10
|
+
path.resolve(__dirname, '..'),
|
|
11
|
+
],
|
|
12
|
+
resolver: {
|
|
13
|
+
nodeModulesPaths: [
|
|
14
|
+
path.resolve(__dirname, 'node_modules'),
|
|
15
|
+
// Add the workspace root node_modules
|
|
16
|
+
path.resolve(__dirname, '..', 'node_modules'),
|
|
17
|
+
],
|
|
18
|
+
// Important for Idealyst to use .native extensions for React Native (eg: @idealyst/components/src/Button/Button.native.tsx)
|
|
19
|
+
sourceExts: ['native.tsx', 'native.ts', 'tsx', 'ts', 'native.jsx', 'native.js', 'jsx', 'js', 'json'],
|
|
20
|
+
},
|
|
21
|
+
watcher: {
|
|
22
|
+
// When configuring custom components with .native extensions, make sure the watcher looks for them
|
|
23
|
+
additionalExts: ['native.tsx', 'native.ts', 'native.jsx', 'native.js'],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = wrapWithReanimatedMetroConfig(mergeConfig(getDefaultConfig(__dirname), config));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "{{packageName}}",
|
|
3
|
-
"version": "{{version}}",
|
|
4
|
-
"description": "{{description}}",
|
|
5
|
-
"private": true,
|
|
6
|
-
"idealyst": {
|
|
7
|
-
"framework": "react-native",
|
|
8
|
-
"version": "1.0.3"
|
|
9
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "{{packageName}}",
|
|
3
|
+
"version": "{{version}}",
|
|
4
|
+
"description": "{{description}}",
|
|
5
|
+
"private": true,
|
|
6
|
+
"idealyst": {
|
|
7
|
+
"framework": "react-native",
|
|
8
|
+
"version": "1.0.3"
|
|
9
|
+
}
|
|
10
10
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
3
|
+
import { httpBatchLink } from '@trpc/client';
|
|
4
|
+
import { UnistylesRegistry } from 'react-native-unistyles';
|
|
5
|
+
import { Screen, Text, View } from '@idealyst/components';
|
|
6
|
+
import { breakpoints, lightTheme, darkTheme } from '@idealyst/theme';
|
|
7
|
+
import { trpc } from './utils/trpc';
|
|
8
|
+
|
|
9
|
+
// Register the Unistyles themes and breakpoints
|
|
10
|
+
UnistylesRegistry
|
|
11
|
+
.addBreakpoints(breakpoints)
|
|
12
|
+
.addThemes({
|
|
13
|
+
light: lightTheme,
|
|
14
|
+
dark: darkTheme,
|
|
15
|
+
})
|
|
16
|
+
.addConfig({
|
|
17
|
+
adaptiveThemes: true,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Create tRPC client
|
|
21
|
+
const queryClient = new QueryClient();
|
|
22
|
+
|
|
23
|
+
const trpcClient = trpc.createClient({
|
|
24
|
+
links: [
|
|
25
|
+
httpBatchLink({
|
|
26
|
+
url: 'http://localhost:3000/trpc', // Update this to your API URL
|
|
27
|
+
// For device testing, you might need: 'http://192.168.1.xxx:3000/trpc'
|
|
28
|
+
// Optional: Add headers for authentication
|
|
29
|
+
// headers() {
|
|
30
|
+
// return {
|
|
31
|
+
// authorization: getAuthToken(),
|
|
32
|
+
// };
|
|
33
|
+
// },
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function App() {
|
|
39
|
+
// Example tRPC usage
|
|
40
|
+
const { data, isLoading, error } = trpc.hello.useQuery({ name: 'React Native' });
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<trpc.Provider client={trpcClient} queryClient={queryClient}>
|
|
44
|
+
<QueryClientProvider client={queryClient}>
|
|
45
|
+
<Screen>
|
|
46
|
+
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', padding: 20 }}>
|
|
47
|
+
<Text variant="h1" style={{ textAlign: 'center', marginBottom: 20 }}>
|
|
48
|
+
Welcome to {{appName}}!
|
|
49
|
+
</Text>
|
|
50
|
+
<Text variant="body" style={{ textAlign: 'center', marginBottom: 20 }}>
|
|
51
|
+
This is a React Native app built with the Idealyst Framework
|
|
52
|
+
</Text>
|
|
53
|
+
|
|
54
|
+
{/* tRPC Example */}
|
|
55
|
+
<View style={{ marginTop: 20, alignItems: 'center' }}>
|
|
56
|
+
<Text variant="h3" style={{ marginBottom: 10 }}>tRPC Example:</Text>
|
|
57
|
+
{isLoading && <Text>Loading...</Text>}
|
|
58
|
+
{error && <Text>Error: {error.message}</Text>}
|
|
59
|
+
{data && <Text style={{ textAlign: 'center' }}>{data.greeting}</Text>}
|
|
60
|
+
</View>
|
|
61
|
+
|
|
62
|
+
<Text variant="caption" style={{ textAlign: 'center', marginTop: 30 }}>
|
|
63
|
+
Edit src/App.tsx to get started
|
|
64
|
+
</Text>
|
|
65
|
+
</View>
|
|
66
|
+
</Screen>
|
|
67
|
+
</QueryClientProvider>
|
|
68
|
+
</trpc.Provider>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default App;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { createTRPCReact } from '@trpc/react-query';
|
|
2
|
+
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
|
|
3
|
+
|
|
4
|
+
// Import your API types here when you have an API project
|
|
5
|
+
// Example: import type { AppRouter } from '@your-workspace/api';
|
|
6
|
+
|
|
7
|
+
// For now, we'll use a generic type that you can replace
|
|
8
|
+
type AppRouter = any;
|
|
9
|
+
|
|
10
|
+
// Create the tRPC React hooks
|
|
11
|
+
export const trpc = createTRPCReact<AppRouter>();
|
|
12
|
+
|
|
13
|
+
// Create a vanilla client (for use outside of React components)
|
|
14
|
+
export const trpcClient = createTRPCProxyClient<AppRouter>({
|
|
15
|
+
links: [
|
|
16
|
+
httpBatchLink({
|
|
17
|
+
url: 'http://localhost:3000/trpc', // Update this to match your API URL
|
|
18
|
+
// Optional: Add headers for authentication
|
|
19
|
+
// headers() {
|
|
20
|
+
// return {
|
|
21
|
+
// authorization: getAuthToken(),
|
|
22
|
+
// };
|
|
23
|
+
// },
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
Usage Examples for React Native:
|
|
30
|
+
|
|
31
|
+
1. First, install the required dependencies:
|
|
32
|
+
yarn add @trpc/client @trpc/react-query @tanstack/react-query
|
|
33
|
+
|
|
34
|
+
2. Replace the AppRouter type import above with your actual API router:
|
|
35
|
+
import type { AppRouter } from '@your-workspace/api';
|
|
36
|
+
|
|
37
|
+
3. Set up the tRPC provider in your App component:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import React from 'react';
|
|
41
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
42
|
+
import { httpBatchLink } from '@trpc/client';
|
|
43
|
+
import { trpc } from './src/utils/trpc';
|
|
44
|
+
|
|
45
|
+
const queryClient = new QueryClient();
|
|
46
|
+
|
|
47
|
+
const trpcClient = trpc.createClient({
|
|
48
|
+
links: [
|
|
49
|
+
httpBatchLink({
|
|
50
|
+
url: 'http://localhost:3000/trpc', // Use your computer's IP for device testing
|
|
51
|
+
// For device testing, you might need: 'http://192.168.1.xxx:3000/trpc'
|
|
52
|
+
}),
|
|
53
|
+
],
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
function App() {
|
|
57
|
+
return (
|
|
58
|
+
<trpc.Provider client={trpcClient} queryClient={queryClient}>
|
|
59
|
+
<QueryClientProvider client={queryClient}>
|
|
60
|
+
{/* Your app components */}
|
|
61
|
+
</QueryClientProvider>
|
|
62
|
+
</trpc.Provider>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default App;
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
4. Use tRPC in your React Native components:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import React from 'react';
|
|
73
|
+
import { View, Text, ScrollView, TouchableOpacity } from 'react-native';
|
|
74
|
+
import { trpc } from '../utils/trpc';
|
|
75
|
+
|
|
76
|
+
function UsersList() {
|
|
77
|
+
const { data: users, isLoading, refetch } = trpc.users.getAll.useQuery();
|
|
78
|
+
const createUser = trpc.users.create.useMutation({
|
|
79
|
+
onSuccess: () => {
|
|
80
|
+
refetch(); // Refresh the list after creating
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (isLoading) {
|
|
85
|
+
return (
|
|
86
|
+
<View>
|
|
87
|
+
<Text>Loading...</Text>
|
|
88
|
+
</View>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<ScrollView>
|
|
94
|
+
{users?.map(user => (
|
|
95
|
+
<View key={user.id}>
|
|
96
|
+
<Text>{user.name}</Text>
|
|
97
|
+
<Text>{user.email}</Text>
|
|
98
|
+
</View>
|
|
99
|
+
))}
|
|
100
|
+
<TouchableOpacity
|
|
101
|
+
onPress={() => createUser.mutate({
|
|
102
|
+
email: 'test@example.com',
|
|
103
|
+
name: 'Test User'
|
|
104
|
+
})}
|
|
105
|
+
>
|
|
106
|
+
<Text>Create User</Text>
|
|
107
|
+
</TouchableOpacity>
|
|
108
|
+
</ScrollView>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
5. For device testing, make sure to:
|
|
114
|
+
- Use your computer's IP address instead of localhost
|
|
115
|
+
- Ensure your API server is accessible from the device
|
|
116
|
+
- Consider using ngrok for external testing
|
|
117
|
+
|
|
118
|
+
6. Error handling example:
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
const { data, error, isLoading } = trpc.users.getAll.useQuery();
|
|
122
|
+
|
|
123
|
+
if (error) {
|
|
124
|
+
return <Text>Error: {error.message}</Text>;
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
*/
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@react-native/typescript-config/tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"allowJs": true,
|
|
5
|
-
"allowSyntheticDefaultImports": true,
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"isolatedModules": true,
|
|
8
|
-
"jsx": "react-native",
|
|
9
|
-
"lib": ["es2017"],
|
|
10
|
-
"moduleResolution": "node",
|
|
11
|
-
"noEmit": true,
|
|
12
|
-
"strict": true,
|
|
13
|
-
"target": "esnext",
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"baseUrl": "./",
|
|
17
|
-
"paths": {
|
|
18
|
-
"@/*": ["./src/*"]
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"include": [
|
|
22
|
-
"src/**/*",
|
|
23
|
-
"index.js"
|
|
24
|
-
],
|
|
25
|
-
"exclude": [
|
|
26
|
-
"node_modules",
|
|
27
|
-
"android",
|
|
28
|
-
"ios"
|
|
29
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"extends": "@react-native/typescript-config/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"allowJs": true,
|
|
5
|
+
"allowSyntheticDefaultImports": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"isolatedModules": true,
|
|
8
|
+
"jsx": "react-native",
|
|
9
|
+
"lib": ["es2017"],
|
|
10
|
+
"moduleResolution": "node",
|
|
11
|
+
"noEmit": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"target": "esnext",
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"baseUrl": "./",
|
|
17
|
+
"paths": {
|
|
18
|
+
"@/*": ["./src/*"]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"include": [
|
|
22
|
+
"src/**/*",
|
|
23
|
+
"index.js"
|
|
24
|
+
],
|
|
25
|
+
"exclude": [
|
|
26
|
+
"node_modules",
|
|
27
|
+
"android",
|
|
28
|
+
"ios"
|
|
29
|
+
]
|
|
30
30
|
}
|