Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.

Commit 51b7ff2

Browse files
authored
Merge pull request #6 from bencompton/alert-changes
change alert and getter for framework7 to ensure framework7 is initia…
2 parents 411b1af + 4f9f6d0 commit 51b7ff2

4 files changed

Lines changed: 34 additions & 29 deletions

File tree

kitchen-sink/dist/index.js

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "framework7-react",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "A library of React components that leverages Framework7 HTML + CSS",
55
"main": "dist/src/index.js",
66
"typings": "dist/src/index.d.ts",

src/components/Alert.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,22 @@ export class Alert extends React.Component<IAlertProps, IAlertModalState> {
4444
}
4545

4646
private get framework7() {
47-
return ((this.context as any).framework7AppContext as IFramework7AppContext).framework7;
47+
return ((this.context as any).framework7AppContext as IFramework7AppContext).getFramework7();
4848
}
4949

5050
private showAlert() {
51-
this.state.modal = this.framework7.modal({
52-
title: this.props.title,
53-
text: this.props.text,
54-
buttons: [{ text: this.framework7.params.modalButtonOk, bold: true, onClick: this.props.onClick }]
55-
});
51+
setTimeout(() => {
52+
if (this.framework7) {
53+
this.state.modal = this.framework7.modal({
54+
title: this.props.title,
55+
text: this.props.text,
56+
buttons: [{ text: this.framework7.params.modalButtonOk, bold: true, onClick: this.props.onClick }]
57+
});
58+
} else {
59+
this.showAlert();
60+
}
61+
}, 100);
62+
5663
}
5764

5865
private hideAlert() {

src/components/Framework7App.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface IFramework7AppContext {
1313
themeType: ThemeTypeEnum;
1414
rtl?: boolean;
1515
pageAnimationDirection: AnimationDirectionEnum;
16-
framework7: Framework7;
16+
getFramework7: () => Framework7;
1717
}
1818

1919
export interface IFramework7AppProps extends React.Props<any> {
@@ -28,15 +28,13 @@ export class Framework7App extends React.Component<IFramework7AppProps, Framewor
2828
framework7AppContext: React.PropTypes.object
2929
}
3030

31-
componentWillRe
32-
3331
getChildContext() {
3432
return {
3533
framework7AppContext: {
3634
themeType: this.props.themeType,
3735
rtl: this.props.rtl,
3836
pageAnimationDirection: this.props.pageAnimationDirection,
39-
framework7: this.state
37+
getFramework7: () => this.state
4038
}
4139
};
4240
}

0 commit comments

Comments
 (0)