I have list of Events that I call using axios.get and map them to an Event component. Inside the Event component I have a button which opens a Registration Component. I'm trying to find a way to pass this.props.title on the React Router Link component.
Events.js
import React from 'react';
import Event from './Event';
var axios = require('axios');
var Events = React.createClass({
getInitialState: function() {
return {
events: [],
}
},
componentDidMount: function() {
var _this = this;
axios.get("MY JSON URL")
.then(function(result) {
_this.setState({
events: result.data
});
})
.catch(function(error) {
console.log(error);
})
},
componentWillUnmount: function() {
this.unmounted = true;
},
render: function() {
return (
<div>
{this.state.events.map(function(event, key) {
return (
<div key={key}>
<Event
title={event.EventTitle}
/>
</div>
)
})}
</div>
)
}
});
export default Events;
Event.js import React from 'react';
var Event = React.createClass({
render: function() {
return (
<div className="ui-outer">
<Link to="/register/event" title={this.props.title} />
</div>
)}})
export default Event;
RegisterForm.js
import React from 'react';
var RegisterForm = React.createClass({
<h1>{this.props.title}</h1>
<form></form>
})
export default RegisterForm;