-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import { submitEntry, removeEntry } from '../utils/api' | |
import { connect } from 'react-redux' | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
AlbertVilaCalvo
|
||
import { addEntry } from '../actions' | ||
import { purple, white } from '../utils/colors' | ||
import { NavigationActions } from 'react-navigation' | ||
|
||
function SubmitBtn ({ onPress }) { | ||
return ( | ||
|
@@ -69,7 +70,7 @@ class AddEntry extends Component { | |
|
||
this.setState(() => ({ run: 0, bike: 0, swim: 0, sleep: 0, eat: 0 })) | ||
|
||
// Navigate to home | ||
this.toHome() | ||
|
||
submitEntry({ key, entry }) | ||
|
||
|
@@ -82,10 +83,13 @@ class AddEntry extends Component { | |
[key]: getDailyReminderValue() | ||
})) | ||
|
||
// Route to Home | ||
this.toHome() | ||
This comment has been minimized.
Sorry, something went wrong.
mostafa-drz
|
||
|
||
removeEntry(key) | ||
} | ||
toHome = () => { | ||
this.props.navigation.dispatch(NavigationActions.back({key: 'AddEntry'})) | ||
} | ||
render() { | ||
const metaInfo = getMetricMetaInfo() | ||
|
||
|
2 comments
on commit 18aeee6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v5
this worked with me
import { CommonActions } from '@react-navigation/native';
then
toHome =
() => {
this.props.navigation.dispatch(
CommonActions.goBack({
key: 'AddEntry',
}))
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2021.09 Version 6 (v6)
Code:
toHome = () =>{
const { navigation } = this.props;
navigation.dispatch(CommonActions.goBack());
}
No need to supply a key
because it gets filled in with the correct value (current route) automatically: https://reactnavigation.org/docs/navigation-actions#goback
Working code for V5