Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sections.jsx based off of your example
  2.  
  3. import React, { useState } from "react";
  4. import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
  5. import { library } from '@fortawesome/fontawesome-svg-core';
  6. import { fas } from '@fortawesome/free-solid-svg-icons';
  7. library.add(fas)
  8.  
  9. const Sections = ({ componentToPassDown }) => {
  10.     const [show, setShow] = useState(false);
  11.     return (
  12.         <section>
  13.             <div className="border">
  14.                 <button
  15.                     onClick={() => {
  16.                         setShow(!show);
  17.                     }}
  18.                 >
  19.                     <FontAwesomeIcon icon={show ? "eye" : "eye-slash"} />
  20.                 </button>
  21.             </div>
  22.             {show && (
  23.                 { componentToPassDown }
  24.             )}
  25.         </section>
  26.     )
  27. }
  28.  
  29. export default Sections;
  30.  
  31. the Return section from Resume.jsx
  32. return (
  33.         <div className="container">
  34.             <div className="cv-header">
  35.                 <h2>Your CV</h2>
  36.             </div>
  37.             <form className="cv-form" onSubmit={jsonFunction}>
  38.                 <Sections componentToPassDown={<General />}/> #trying to pass <General /> as a prop
  39.                 <Sections />
  40.                 <Sections />
  41.                 <old function that used querySelector />
  42.                 <General {...{handleGeneralInputChange}}/> #how I had it before
  43.                 <old function that used querySelector />
  44.                 <WorkHistory {...{handleJobInput}} />
  45.                 <old function that used querySelector />
  46.                 <AllSkills />
  47.                 <br />
  48.                 <div className="submit-container">
  49.                     <button type="submit">Submit</button>
  50.                 </div>
  51.             </form>
  52.         </div>
  53.     )
  54.  
  55. General.jsx for reference
  56.  
  57. import React from "react"
  58. import Name from "./Name.jsx"
  59. import Address from "./Address.jsx"
  60. import "./main.css"
  61. const General = ({handleGeneralInputChange}) => {
  62.     return (
  63.         <div data-is-general className="general">
  64.             <Name {...{handleGeneralInputChange}}/>
  65.             <Address {...{handleGeneralInputChange}}/>
  66.             <div className="section-divider"></div>
  67.             <br />
  68.         </div>
  69.     )
  70. }
  71.  
  72. export default General;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement