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

10-modal-development #49

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

10-modal-development #49

wants to merge 3 commits into from

Conversation

kasiarog
Copy link
Collaborator

No description provided.

Copy link
Member

@Aeri4a Aeri4a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Firstly, good job!
Step by step it is looking more and more interesting :)
So the main idea is to make this component dependent on the props, to control it outside itself, try to think about it.

return (
<div className={styles.modalBackground}>
<div className={styles.modalContainer}>
const ModalWidget = ({header, paragraph, cancelText, confirmText, onConfirm,}) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is unnecessary comma after last prop

Comment on lines +7 to +10
const [openModal, setOpenModal] = useState(true);
const switchModal = () => {
setOpenModal(!openModal);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openModal should be passed as a prop "open" and then we will be able to control the state outside the component

<button className={`${styles.modalButton} ${styles.confirm}`}>Confirm</button>
</div>
</div>
document.body.addEventListener('keydown', pressEscape);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move it to useEffect function, but not the returned one, above return.


return (
<div>
<button onClick={switchModal}> Show modal </button>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we will have open prop state, then we don't have to have a button here :)

Comment on lines +42 to +45
<button className={`${styles.modalButton} ${styles.cancel}`} onClick={switchModal}>
{cancelText}
</button>
<button className={`${styles.modalButton} ${styles.confirm}`} onClick={pressConfirm}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onClick can just include function which will be passed and we don't have to wrap it with another one

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.

2 participants