-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix issue #6 : Create CommentsOverlay component #9
Conversation
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.
Nice work. I've made some comments, have a look.
ui/Comments/BackButton.tsx
Outdated
const onBackHandler = () => { | ||
props.onBack(); | ||
}; | ||
|
||
return ( | ||
<TouchableOpacity onPress={onBackHandler} activeOpacity={0.5}> |
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.
Directly pass props.onBack
into TouchableOpacity
- no need to create a separate onBackHandler
function.
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.
I thought it would increase readability and hence created separate functions for many one liner functions also. Should I remove them all or is this specific?
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.
A separate function increases readability if it represents a separate action. In this case, both onBackHandler
and props.onBack
mean the same thing - a function to be called for going back. Then a separate function is not necessary.
ui/Comments/CommentBlock.tsx
Outdated
}; | ||
|
||
const CommentBox = (props: Props) => { | ||
let inpRef: React.RefObject<TextInput> = createRef(); |
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.
You probably want to use a useRef
here, instead of createRef
. Read this SO answer.
ui/Comments/CommentBlock.tsx
Outdated
isVisible={true} | ||
fullScreen={true} |
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.
tip: instead of isVisible={true}
, you can simply write isVisible
- same for fullScreen
. Just syntactic sugar.
ui/Comments/index.tsx
Outdated
type Props = { | ||
isVisible: boolean; | ||
onBack: (arg0?: Function) => void; | ||
comments: Array<IComment>; | ||
}; | ||
|
||
const CommentBox = (props: Props) => { | ||
let [isVisible, setIsVisible] = useState(props.isVisible); | ||
|
||
const BackHandler = () => { | ||
props.onBack(setIsVisible); | ||
}; | ||
|
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.
I don't get why props.onBack
is defined like that - why do you need to pass setIsVisible
into props.onBack
?
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.
I was thinking that from screen one would may instead of re-rendering may want to just make comment overlay off by using the setIsVisible but later I realized to make it visible again it has to be re-rendered, and forget to remove it. Will remove it.
4d6decc
to
a719e34
Compare
Implemented all suggested changes |
Fixed with #19. |
Created a comments overlay container. Currently contains an example, after approval will be removed. Currently, it displays max 3 hidden replies which can be changed from CommentList container. onReply function in ReplyBox component logs to console which can be integrated with backend using parent comment information. Resolves #6