Search code examples
reactjsmodal-window

Modal windows in React


Here you can see my code in React.js

I want to have several modal windows in one React component. I tried to use Modal from “react-native”, but it didn’t work.

Now I’m trying to use my own realisation of modal window, you can see it here. I want to use this component for creating modal windows according to parameters.

Unfortunately, this component creates modal windows with default values (null). I have watched lots of tutorials, but I still don’t know how to fix it.

I will be very grateful for help.


Solution

  • I asume that you are passing some value to title.
    You can add some ternary operators in the jsx structure:

    <div className="modalTitle">{title ? title : "what ever value you want"}</div>
    

    Or you can add/set loader:

    return (
          <>
            {title ? (
              <div>Your modal content here</div>
            ) : (
              <div>Your loader here</div>
            )}
          </>
          );