Skip to content

Commit cb8f644

Browse files
chore: restructure READMEs
- Make packages/react-native-sandbox/README.md more about API - Root README.md is more generic
1 parent a84c0f7 commit cb8f644

File tree

2 files changed

+47
-62
lines changed

2 files changed

+47
-62
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ npm install @callstack/react-native-sandbox
2323

2424
- [💡 Project Overview](#-project-overview)
2525
- [📝 API Example](#-api-example)
26+
- [📚 API Reference](#-api-reference)
2627
- [🎨 Roadmap](#-roadmap)
2728
- [🔒 Security Considerations](#-security-considerations)
2829
- [TurboModules](#turbomodules)
@@ -93,7 +94,7 @@ function HostApp() {
9394
<Button onPress={sendMessageToSandbox} title="Send to Sandbox" />
9495
<SandboxReactNativeView ref={sandboxRef}
9596
jsBundleSource={"sandbox"} // The JS bundle: file name or URL
96-
componentName={"SandboxApp"} // The name of your JS component from jsBundleSource
97+
componentName={"SandboxApp"} // Name of component registered in bundle provided with jsBundleSource
9798
onMessage={handleMessage}
9899
onError={handleError}
99100
/>
@@ -143,6 +144,10 @@ function SandboxApp() {
143144
AppRegistry.registerComponent("SandboxApp", () => App);
144145
```
145146
147+
## 📚 API Reference
148+
149+
For comprehensive API documentation, installation instructions, and advanced usage patterns, see the [package documentation](https://github.com/callstackincubator/react-native-sandbox/blob/main/packages/react-native-sandbox/README.md).
150+
146151
## 🎨 Roadmap
147152
148153
We're actively working on expanding the capabilities of `react-native-sandbox`. Here's what's planned:

packages/react-native-sandbox/README.md

Lines changed: 41 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![npm version](https://badge.fury.io/js/@callstack%2Freact-native-sandbox.svg)](https://badge.fury.io/js/@callstack%2Freact-native-sandbox)
44
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/callstackincubator/react-native-sandbox/blob/main/LICENSE)
55

6-
> **Library Documentation** - For project overview, examples, and security considerations, see the [main repository README](../../README.md).
6+
> **Library Documentation** - For project overview, examples, and security considerations, see the [main repository README](https://github.com/callstackincubator/react-native-sandbox#readme).
77
88
This is the **developer documentation** for installing and using `@callstack/react-native-sandbox` in your React Native application.
99

@@ -27,13 +27,13 @@ The package uses **autolinking** and supports the **React Native New Architectur
2727
2828
## 🎯 Basic Usage
2929

30-
> For complete examples with both host and sandbox code, see the [project examples](../../README.md#-api-example).
30+
> For complete examples with both host and sandbox code, see the [project examples](https://github.com/callstackincubator/react-native-sandbox#-api-example).
3131
3232
```tsx
3333
import SandboxReactNativeView from '@callstack/react-native-sandbox';
3434

3535
<SandboxReactNativeView
36-
componentName="YourSandboxComponent"
36+
componentName="YourSandboxComponent" // Name of component registered in bundle provided with jsBundleSource
3737
jsBundleSource="sandbox" // bundle file name
3838
onMessage={(data) => console.log('From sandbox:', data)}
3939
onError={(error) => console.error('Sandbox error:', error)}
@@ -51,7 +51,7 @@ import SandboxReactNativeView from '@callstack/react-native-sandbox';
5151
| `jsBundleSource` | `string` | :ballot_box_with_check: | - | Name on file storage or URL to the JavaScript bundle to load |
5252
| `initialProperties` | `object` | :white_large_square: | `{}` | Initial props for the sandboxed app |
5353
| `launchOptions` | `object` | :white_large_square: | `{}` | Launch configuration options |
54-
| `allowedTurboModules` | `string[]` | :white_large_square: | [check here](./src/index.tsx#L18) | Additional TurboModules to allow |
54+
| `allowedTurboModules` | `string[]` | :white_large_square: | [check here](https://github.com/callstackincubator/react-native-sandbox/blob/main/packages/react-native-sandbox/src/index.tsx#L18) | Additional TurboModules to allow |
5555
| `onMessage` | `function` | :white_large_square: | `undefined` | Callback for messages from sandbox |
5656
| `onError` | `function` | :white_large_square: | `undefined` | Callback for sandbox errors |
5757
| `style` | `ViewStyle` | :white_large_square: | `undefined` | Container styling |
@@ -77,7 +77,7 @@ interface ErrorEvent {
7777

7878
## 🔒 Security & TurboModules
7979

80-
> For detailed security considerations, see the [Security section](../../README.md#-security-considerations) in the main README.
80+
> For detailed security considerations, see the [Security section](https://github.com/callstackincubator/react-native-sandbox#-security-considerations) in the main README.
8181
8282
This package is built with **React Native New Architecture** using Fabric for optimal performance and type safety.
8383

@@ -92,7 +92,7 @@ Use `allowedTurboModules` to control which native modules the sandbox can access
9292
/>
9393
```
9494

95-
**Default allowed modules** include essential React Native TurboModules like `EventDispatcher`, `AppState`, `Networking`, etc. See the [source code](./src/index.tsx) for the complete list.
95+
**Default allowed modules** include essential React Native TurboModules like `EventDispatcher`, `AppState`, `Networking`, etc. See the [source code](https://github.com/callstackincubator/react-native-sandbox/blob/main/packages/react-native-sandbox/src/index.tsx) for the complete list.
9696

9797
> Note: This filtering works with both legacy native modules and new TurboModules, ensuring compatibility across React Native versions.
9898
@@ -158,7 +158,7 @@ useEffect(() => {
158158

159159
return (
160160
<SandboxReactNativeView
161-
componentName="DynamicApp"
161+
componentName="DynamicApp" // Name of component registered in bundle provided with jsBundleSource
162162
jsBundleSource={bundleUrl}
163163
initialProperties={{
164164
userId: currentUser.id,
@@ -168,27 +168,6 @@ return (
168168
);
169169
```
170170

171-
### Error Recovery Pattern
172-
173-
```tsx
174-
const [sandboxKey, setSandboxKey] = useState(0);
175-
176-
const handleError = (error: ErrorEvent) => {
177-
if (error.isFatal) {
178-
// Force re-mount to recover from fatal errors
179-
setSandboxKey(prev => prev + 1);
180-
}
181-
};
182-
183-
return (
184-
<SandboxReactNativeView
185-
key={sandboxKey} // Re-mount on fatal errors
186-
onError={handleError}
187-
// ... other props
188-
/>
189-
);
190-
```
191-
192171
### Performance Monitoring
193172

194173
```tsx
@@ -205,20 +184,9 @@ const handleMessage = (data: unknown) => {
205184
### Memory Management
206185

207186
- Each sandbox creates a separate JavaScript context
208-
- Limit the number of concurrent sandbox instances
209187
- Use `key` prop to force re-mount when needed
210188
- Monitor memory usage in production
211189

212-
### Bundle Optimization
213-
214-
```tsx
215-
// ✅ Good: Small, focused bundles
216-
jsBundleSource="micro-app-dashboard.bundle.js"
217-
218-
// ❌ Avoid: Large monolithic bundles
219-
jsBundleSource="entire-app-with-everything.bundle.js"
220-
```
221-
222190
### Communication Efficiency
223191

224192
```tsx
@@ -254,36 +222,48 @@ jsBundleSource="micro-app.jsbundle"
254222
allowedTurboModules={['MyModule']}
255223
```
256224

257-
### Debug Mode
258-
259-
Enable additional logging:
260-
225+
**3. Fatal Error Recovery**
261226
```tsx
262-
// In development
263-
const isDebug = __DEV__;
264-
227+
// ❌ Sandbox crashed and won't recover
265228
<SandboxReactNativeView
266-
componentName="DebugApp"
267-
launchOptions={{ debug: isDebug }}
268229
onError={(error) => {
269-
if (isDebug) {
270-
console.log('Full error details:', error);
271-
}
230+
console.log('Error:', error);
231+
// Sandbox remains broken after fatal error
272232
}}
273233
/>
234+
235+
// ✅ Auto-recover from fatal errors by re-mounting
236+
const [sandboxKey, setSandboxKey] = useState(0);
237+
238+
const handleError = (error: ErrorEvent) => {
239+
if (error.isFatal) {
240+
// Force re-mount to recover from fatal errors
241+
setSandboxKey(prev => prev + 1);
242+
}
243+
};
244+
245+
<SandboxReactNativeView
246+
key={sandboxKey} // Re-mount on fatal errors
247+
componentName={"SandboxedApp"} // Name of component registered in bundle provided with jsBundleSource
248+
jsBundleSource={"sandbox"}
249+
onError={handleError}
250+
/>
274251
```
275252

276-
## 🐛 Known Issues
253+
**4. Bundle Size Performance Issues**
254+
```tsx
255+
// ❌ Avoid: Large monolithic bundles (slow loading)
256+
jsBundleSource="entire-app-with-everything.bundle.js"
277257

278-
### iOS
279-
- Multiple rapid sandbox creation/destruction may cause memory spikes
280-
- Large bundles (>10MB) may impact initial load time
281-
- First sandbox load may be slower due to JavaScript context initialization
258+
// ✅ Good: Small, focused bundles (fast loading)
259+
jsBundleSource="micro-app-dashboard.bundle.js"
260+
// or
261+
jsBundleSource="https://cdn.example.com/lightweight-feature.bundle.js"
262+
```
282263

283264
## 📄 More Information
284265

285-
- **📖 Project Overview & Examples**: [Main README](../../README.md)
286-
- **🔒 Security Considerations**: [Security Documentation](../../README.md#-security-considerations)
287-
- **🎨 Roadmap**: [Development Plans](../../README.md#-roadmap)
288-
- **🐛 Issues**: [GitHub Issues](https://github.com/callstackincubator/react-native-sandbox/issues)
289-
- **📦 npm**: [@callstack/react-native-sandbox](https://www.npmjs.com/package/@callstack/react-native-sandbox)
266+
- **📖 Project Overview & Examples**: [Main README](https://github.com/callstackincubator/react-native-sandbox#readme)
267+
- **🔒 Security Considerations**: [Security Documentation](https://github.com/callstackincubator/react-native-sandbox#-security-considerations)
268+
- **🎨 Roadmap**: [Development Plans](https://github.com/callstackincubator/react-native-sandbox#-roadmap)
269+
- **🐛 Issues**: [GitHub Issues](https://github.com/callstackincubator/react-native-sandbox/issues)

0 commit comments

Comments
 (0)