aboutsummaryrefslogtreecommitdiff
path: root/src/components/comments/AddComment.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/comments/AddComment.tsx')
-rw-r--r--src/components/comments/AddComment.tsx13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/components/comments/AddComment.tsx b/src/components/comments/AddComment.tsx
index ac1628da..f8c0b6bc 100644
--- a/src/components/comments/AddComment.tsx
+++ b/src/components/comments/AddComment.tsx
@@ -7,9 +7,11 @@ import {
View,
} from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
-import {AuthContext} from '../../routes';
import {TaggBigInput} from '../onboarding';
import {postMomentComment} from '../../services';
+import {logout} from '../../store/actions';
+import {useSelector, useDispatch} from 'react-redux';
+import {RootState} from '../../store/rootreducer';
/**
* This file provides the add comment view for a user.
@@ -27,11 +29,12 @@ const AddComment: React.FC<AddCommentProps> = ({
moment_id,
}) => {
const [comment, setComment] = React.useState('');
+
+ const dispatch = useDispatch();
const {
avatar,
- user: {userId, username},
- logout,
- } = React.useContext(AuthContext);
+ user: {userId},
+ } = useSelector((state: RootState) => state.user);
const handleCommentUpdate = (comment: string) => {
setComment(comment);
@@ -41,7 +44,7 @@ const AddComment: React.FC<AddCommentProps> = ({
try {
const token = await AsyncStorage.getItem('token');
if (!token) {
- logout();
+ dispatch(logout());
return;
}
const postedComment = await postMomentComment(