Skip to content

Commit

Permalink
fixSimpleEditor: remove non-null assertion for user selector
Browse files Browse the repository at this point in the history
- Removed non-null assertion from selectUser selector to handle cases where user might be null.
- Updated completeTask function call to use optional chaining for user.id to
  • Loading branch information
ryota-murakami committed Jul 26, 2024
1 parent 1cccf7e commit 6f0e3af
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/SimpleEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const SimpleEditor: React.FC<ComponentProps<'textarea'>> = ({
const dispatch = useAppDispatch()
const currentCategory = useAppSelector(selectCurrentCategory)
const editorText = useAppSelector(selectCurrentText)
const user = useAppSelector(selectUser)!
const user = useAppSelector(selectUser)
const selectedRef = useRef<string>('')

// TODO change to CSS based implementation
Expand All @@ -48,7 +48,7 @@ const SimpleEditor: React.FC<ComponentProps<'textarea'>> = ({
async function taskCompleted() {
try {
dispatch(removeCompletedTaskFromEditorText(selectedRef.current!))
await completeTask(selectedRef.current!, currentCategory, user.id)
await completeTask(selectedRef.current!, currentCategory, user?.id)

Check failure on line 51 in src/components/SimpleEditor.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
toast.success('Task Completed! 🎉')
} catch (error) {
toast.error('Failed to complete task')
Expand Down

0 comments on commit 6f0e3af

Please sign in to comment.