You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the class for modal shows the transparent underlay throughout the whole application (not just when clicking on details). #modal { background-color: rgba(0, 0, 0, 0.9); position: fixed; left: 0; right: 0; bottom: 0; top: 0; z-index: 10; display: flex; justify-content: center; align-items: center; }
Im not sure how to get rid of this underlay programmatically and showing it on the details page only
Here is my modal module :
`/* eslint-disable react-hooks/rules-of-hooks */
// eslint-disable-next-line react-hooks/rules-of-hooks
import React, { useEffect, useRef } from "react";
import { createPortal } from "react-dom";
const Modal = ({ children }) => {
const elRef = useRef(null);
if (!elRef.current) {
elRef.current = document.createElement("div");
}
here is my details module
`
import React from 'react'
import pet from '@frontendmasters/pet'
import {navigate} from '@reach/router'
import Modal from './Modal'
import Carousel from './Carousel'
import ErrorBoundary from './ErrorBoundary'
import ThemeContext from './ThemeContext'
class Details extends React.Component {
constructor(props){
super(props);
this.state = {
loading: true,
showModal: false
}
When making the modal
<div id="modal" > </div>
the class for modal shows the transparent underlay throughout the whole application (not just when clicking on details).
#modal { background-color: rgba(0, 0, 0, 0.9); position: fixed; left: 0; right: 0; bottom: 0; top: 0; z-index: 10; display: flex; justify-content: center; align-items: center; }
Im not sure how to get rid of this underlay programmatically and showing it on the details page only
Here is my modal module :
`/* eslint-disable react-hooks/rules-of-hooks */
// eslint-disable-next-line react-hooks/rules-of-hooks
import React, { useEffect, useRef } from "react";
import { createPortal } from "react-dom";
const Modal = ({ children }) => {
const elRef = useRef(null);
if (!elRef.current) {
elRef.current = document.createElement("div");
}
useEffect(() => {
const modalRoot = document.getElementById("modal");
modalRoot.appendChild(elRef.current);
return () => modalRoot.removeChild(elRef.current);
}, []);
return createPortal(
};
export default Modal;
`
here is my details module
`
import React from 'react'
import pet from '@frontendmasters/pet'
import {navigate} from '@reach/router'
import Modal from './Modal'
import Carousel from './Carousel'
import ErrorBoundary from './ErrorBoundary'
import ThemeContext from './ThemeContext'
class Details extends React.Component {
constructor(props){
super(props);
this.state = {
loading: true,
showModal: false
}
}
export default function ErrorBoundaryFromDetails (props) {
return (
<Details {...props} />
)
}`
NOt sure about the whole showModal: true .. how does this change the classes or tell where to close the portal?
The text was updated successfully, but these errors were encountered: