New to ReactJS. I'm mapping over an array of data, some of which are strings with HTML tags. I'm trying to figure out how to render the html so that it's functional HTML. Currently it's outputted as a string in the browser.
Data:
const PROJECTS = [
{
id: 1,
title: 'Website',
dates: 'December 2015 - December 2017',
description: 'Did some freelance work for <a href="www.website.com">website.com</a>.',
},
{
id: 2,
title: 'Website',
dates: 'December 2015 - December 2017',
description: 'Did some freelance work for <a href="www.website.com">website.com</a>.',
}
];
export default PROJECTS;
React Component
import React, { Component } from 'react';
import PROJECTS from '../data/projects';
class Projects extends Component {
render() {
return (
<div>
{PROJECTS.map(PROJECT => {
return(
<article key={PROJECT.id}>
<h2>{PROJECT.title}</h2>
<p>{PROJECT.dates}</p>
<p>{PROJECT.description}</p>
</article>
)
})}
</div>
)
}
}
export default Projects;