Refactor how data from files are handled

This commit is contained in:
Mitchell Simon 2019-09-03 02:35:13 -04:00
parent e9ffbad7ca
commit 1aebe5ebcf
2 changed files with 6 additions and 14 deletions

View File

@ -1,7 +1,7 @@
import React, { PureComponent, ReactNode } from "react"
import Job from "../../components/Job"
import jobsData from "../../data/jobs.json"
import jobs from "../../data/jobs.json"
import "./index.css"
type JobData = {
@ -13,12 +13,10 @@ type JobData = {
export default class Experience extends PureComponent {
public render(): ReactNode {
return (
<div className="experience-container">{this.renderJobs(jobsData)}</div>
)
return <div className="experience-container">{this.renderJobs()}</div>
}
private renderJobs(jobs: JobData[]): ReactNode[] {
private renderJobs(): ReactNode[] {
return jobs.map((job: JobData) => (
<Job
key={job.title}

View File

@ -1,11 +1,9 @@
import React, { PureComponent, ReactNode } from "react"
import Project from "../../components/Project"
import projects from "../../data/projects.json"
import "./index.css"
import projectsData from "../../data/projects.json"
type BadgeData = {
imgUrl: string
linkUrl: string
@ -21,14 +19,10 @@ type ProjectData = {
export default class Projects extends PureComponent {
public render(): ReactNode {
return (
<div className="projects-container">
{this.renderProjects(projectsData)}
</div>
)
return <div className="projects-container">{this.renderProjects()}</div>
}
private renderProjects(projects: ProjectData[]): ReactNode[] {
private renderProjects(): ReactNode[] {
return projects.map((project: ProjectData) => (
<Project
key={project.title}