Skip to content

Commit eeff95b

Browse files
author
Srđan Tubin
authored
Merge pull request #65 from adjust/react-updates-sync
Sync README and Example app with ReactJS updates
2 parents 265519b + e0595db commit eeff95b

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ You should use the following import statement on top of your `.js` file
127127
import { Adjust, AdjustEvent, AdjustConfig } from 'react-native-adjust';
128128
```
129129

130-
In your `index.android.js` or `index.ios.js` file, add the following code to initialize the Adjust SDK:
130+
In your `App.js` file, add the following code to initialize the Adjust SDK:
131131

132132
```javascript
133-
componentWillMount() {
134-
var adjustConfig = new AdjustConfig("{YourAppToken}", AdjustConfig.EnvironmentSandbox);
133+
constructor(props) {
134+
super(props);
135+
const adjustConfig = new AdjustConfig("{YourAppToken}", AdjustConfig.EnvironmentSandbox);
135136
Adjust.create(adjustConfig);
136137
}
137138

example/App.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,9 @@
44

55
type Props = {};
66
export default class App extends Component<Props> {
7-
componentDidMount() {
8-
Linking.addEventListener('url', this.handleDeepLink);
9-
Linking.getInitialURL().then((url) => {
10-
if (url) {
11-
this.handleDeepLink({ url });
12-
}
13-
})
14-
}
7+
constructor(props) {
8+
super(props);
159

16-
componentWillMount() {
1710
this._onPress_trackSimpleEvent = this._onPress_trackSimpleEvent.bind(this);
1811
this._onPress_trackRevenueEvent = this._onPress_trackRevenueEvent.bind(this);
1912
this._onPress_trackCallbackEvent = this._onPress_trackCallbackEvent.bind(this);
@@ -29,7 +22,7 @@
2922
console.log("Adjust SDK version: " + sdkVersion);
3023
});
3124

32-
var adjustConfig = new AdjustConfig("2fm9gkqubvpc", AdjustConfig.EnvironmentSandbox);
25+
const adjustConfig = new AdjustConfig("2fm9gkqubvpc", AdjustConfig.EnvironmentSandbox);
3326
adjustConfig.setLogLevel(AdjustConfig.LogLevelVerbose);
3427
adjustConfig.setShouldLaunchDeeplink(true);
3528
adjustConfig.setSendInBackground(true);
@@ -116,6 +109,15 @@
116109
// Adjust.sendFirstPackages();
117110
}
118111

112+
componentDidMount() {
113+
Linking.addEventListener('url', this.handleDeepLink);
114+
Linking.getInitialURL().then((url) => {
115+
if (url) {
116+
this.handleDeepLink({ url });
117+
}
118+
})
119+
}
120+
119121
componentWillUnmount() {
120122
Adjust.componentWillUnmount();
121123
Linking.removeEventListener('url', this.handleDeepLink);

test/app/App.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040

4141
type Props = {};
4242
export default class App extends Component<Props> {
43-
componentWillMount() {
43+
constructor(props) {
44+
super(props);
45+
4446
var baseUrl = "";
4547
var gdprUrl = "";
4648
if (Platform.OS === "android") {

0 commit comments

Comments
 (0)