Skip to content

Commit c1552e3

Browse files
committed
feat: add support for lower case restart function, deprecate camel case
1 parent 61943c3 commit c1552e3

File tree

8 files changed

+26
-7
lines changed

8 files changed

+26
-7
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ jobs:
2323
with:
2424
filters: |
2525
android:
26-
- 'android/**'
27-
- 'Example/android/**'
26+
- 'android/*/**'
27+
- 'Example/android/*/**'
2828
ios:
29-
- 'ios/**'
30-
- 'Example/ios/**'
29+
- 'ios/*/**'
30+
- 'Example/ios/*/**'
3131
3232
setup:
3333
name: Setup code and environment needed for building, linting and tests

Example/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function App(): JSX.Element {
8080
backgroundColor: isDarkMode ? Colors.black : Colors.white,
8181
}}>
8282
<Section title="Step Zero">
83-
<TouchableOpacity onPress={() => RNRestart.Restart()}>
83+
<TouchableOpacity onPress={() => RNRestart.restart()}>
8484
<View style={styles.restartButton}>
8585
<Text>Restart</Text>
8686
</View>

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ Remember to run `cd ios && pod install` to update files used by Xcode.
143143
import RNRestart from 'react-native-restart'; // Import package from node modules
144144

145145
// Immediately reload the React Native Bundle
146-
RNRestart.Restart();
146+
RNRestart.Restart(); // Deprecated
147+
RNRestart.restart();
147148
```
148149

149150
## Contributing

android/src/main/java/com/reactnativerestart/RestartModule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ public void Restart() {
9999
ProcessPhoenix.triggerRebirth(getReactApplicationContext());
100100
}
101101

102+
@ReactMethod
103+
public void restart() {
104+
ProcessPhoenix.triggerRebirth(getReactApplicationContext());
105+
}
106+
102107
@Override
103108
public String getName() {
104109
return "RNRestart";

ios/Restart.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,15 @@ - (void)loadBundle
2020
return;
2121
}
2222

23+
RCT_EXPORT_METHOD(restart) {
24+
if ([NSThread isMainThread]) {
25+
[self loadBundle];
26+
} else {
27+
dispatch_sync(dispatch_get_main_queue(), ^{
28+
[self loadBundle];
29+
});
30+
}
31+
return;
32+
}
33+
2334
@end

src/__mocks__/react-native-restart.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
export default {
44
Restart: jest.fn(),
5+
restart: jest.fn(),
56
};

src/__tests__/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import RNRestart from "react-native-restart";
55

66
describe("test RNRestart API functions", () => {
77
it("calls the restart function", () => {
8-
RNRestart.Restart();
8+
RNRestart.restart();
99
});
1010
});

src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { RNRestart } = NativeModules;
44

55
type RestartType = {
66
Restart(): void;
7+
restart(): void;
78
};
89

910
export default RNRestart as RestartType;

0 commit comments

Comments
 (0)