Skip to content

Commit 4f07243

Browse files
committed
change the bundle root of widget to index.widget.js
1 parent 6c3754e commit 4f07243

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ You could use `$ npm i react-native-today-widget --save` as well, but don't forg
4141

4242
### Usage
4343

44-
All you need is to create an index.widget.js at the root and register your component for key `TodayWidgetExtension` in your `index.widget.js`
44+
All you need is to create an `index.widget.js` file at the root and register there your component for key `TodayWidgetExtension`:
4545

4646
```jsx
4747
const TodayWidget = () => (
@@ -54,10 +54,8 @@ const TodayWidget = () => (
5454

5555
AppRegistry.registerComponent('TodayWidgetExtension', () => TodayWidget);
5656
```
57-
### Note
58-
please note that registering the widget and the app in index.js file can cause memory issues.
59-
because the app is also bundled (even if you don't need it in your app), and it causes 'Unable to load' errors.
60-
when we devide it to 2 different files, the widget and the app, are bundled seperately.
57+
58+
> Please note that registering both the widget and the main app in `index.js` file can cause memory issues. Because the app is also bundled (even if you don't use it in your widget), and it causes 'Unable to load' error. When we split the registration into two different files, the widget and the main app are bundled seperately. See [blog post from Maxim Toyberman](https://medium.com/@maximtoyberman/building-a-react-native-today-widget-in-ios-102830825e42).
6159
6260
In place of `TodayWidget` component, you could use any JSX component. See [Basic example](./Examples/Basic/index.ios.js#L34).
6361

ios/TodayWidgetExtension/TodayViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ @implementation TodayViewController
2727

2828
- (void)loadView {
2929

30-
NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
30+
NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.widget" fallbackResource:nil];
3131

3232
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
3333
moduleName:@"TodayWidgetExtension"

0 commit comments

Comments
 (0)