Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

devanshusingla
Copy link

@devanshusingla devanshusingla commented Jul 24, 2020

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

Copy link
Collaborator

@nilaymaj nilaymaj left a 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.

Comment on lines 10 to 15
const onBackHandler = () => {
props.onBack();
};

return (
<TouchableOpacity onPress={onBackHandler} activeOpacity={0.5}>
Copy link
Collaborator

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.

Copy link
Author

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?

Copy link
Collaborator

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.

};

const CommentBox = (props: Props) => {
let inpRef: React.RefObject<TextInput> = createRef();
Copy link
Collaborator

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.

Comment on lines 28 to 29
isVisible={true}
fullScreen={true}
Copy link
Collaborator

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/MainComment.tsx Outdated Show resolved Hide resolved
Comment on lines 9 to 21
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);
};

Copy link
Collaborator

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?

Copy link
Author

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.

@devanshusingla devanshusingla force-pushed the master branch 2 times, most recently from 4d6decc to a719e34 Compare July 27, 2020 16:05
@devanshusingla
Copy link
Author

devanshusingla commented Jul 27, 2020

Implemented all suggested changes

@kartikcode
Copy link
Member

Fixed with #19.

@kartikcode kartikcode closed this Jul 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create CommentsOverlay component
3 participants