Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sections.jsx based off of your example
- import React, { useState } from "react";
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
- import { library } from '@fortawesome/fontawesome-svg-core';
- import { fas } from '@fortawesome/free-solid-svg-icons';
- library.add(fas)
- const Sections = ({ componentToPassDown }) => {
- const [show, setShow] = useState(false);
- return (
- <section>
- <div className="border">
- <button
- onClick={() => {
- setShow(!show);
- }}
- >
- <FontAwesomeIcon icon={show ? "eye" : "eye-slash"} />
- </button>
- </div>
- {show && (
- { componentToPassDown }
- )}
- </section>
- )
- }
- export default Sections;
- the Return section from Resume.jsx
- return (
- <div className="container">
- <div className="cv-header">
- <h2>Your CV</h2>
- </div>
- <form className="cv-form" onSubmit={jsonFunction}>
- <Sections componentToPassDown={<General />}/> #trying to pass <General /> as a prop
- <Sections />
- <Sections />
- <old function that used querySelector />
- <General {...{handleGeneralInputChange}}/> #how I had it before
- <old function that used querySelector />
- <WorkHistory {...{handleJobInput}} />
- <old function that used querySelector />
- <AllSkills />
- <br />
- <div className="submit-container">
- <button type="submit">Submit</button>
- </div>
- </form>
- </div>
- )
- General.jsx for reference
- import React from "react"
- import Name from "./Name.jsx"
- import Address from "./Address.jsx"
- import "./main.css"
- const General = ({handleGeneralInputChange}) => {
- return (
- <div data-is-general className="general">
- <Name {...{handleGeneralInputChange}}/>
- <Address {...{handleGeneralInputChange}}/>
- <div className="section-divider"></div>
- <br />
- </div>
- )
- }
- export default General;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement