Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

How to get link value from Carousel image in React JS

I'm learning React JS and trying to create a linkable carousel image using nuka-carousel. I'm trying to click on the slide in the carousel and link then link to the page referenced in the code below. I've set up a data file to grab the images and the data(like in the react tutorial) for the links etc in the example below;

const RollList = [
  {
    headline: "Something Here 1",
    paragraph: "Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod.",
    img_src: "http://placehold.it/755x435/ffffff/c0392b/&text=slide1",
    link: "/about",
    id: "roll-1"
    },
];
export default RollList;

The images load fine into the carousel, but I'm struggling to get the value of the link address from the function. I know it's available in the props as I can see it in the react dev tools plugin. Here's the rest of my code for the component:

var React = require('react');
import RollList from '../../data/roll';
var Carousel = require('nuka-carousel');
import { browserHistory } from 'react-router';
import { Link } from 'react-router';
const MonCarousel = React.createClass({
    mixins: [Carousel.ControllerMixin],

handleLink(event) {
    let linkName= event.target.value;
    console.log(linkName);
    // let path = `${linkName}`;
    // browserHistory.push(path);
},

render() {
    let moncarousel = RollList.map((roll) => {
        return (
            <img src={ roll.img_src } key={roll.id} onClick={this.handleLink} value={roll.link} onLoad={() => {window.dispatchEvent(new Event('resize'));}}/>
        );
    });
    return (
        <div>
            <section class='carousel-section'>
                <div class='container'>
                    <div className="featured-row">
                        <div className="carousel-block">
                            <h4>Featured</h4>
                            <div className="carousel-shadow">
                                <Carousel speed={1200} autoplayInterval={7999} autoplay={true} wrapAround={true}>
                                    { moncarousel }
                                </Carousel>
                            </div>
                        </div>
                        <div className="carousel-side">
                            <div className="btn yel-btn">
                                Get in touch with us
                            </div>
                            <small>something here</small>
                            <br />
                            <br />
                            <div className="btn yel-btn">
                                Get in touch with us
                            </div>
                            <small>something here</small>
                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur sequi, minus molestiae perspiciatis, debitis adipisci eaque in recusandae voluptatum! Reiciendis enim vero expedita eaque placeat eligendi tempore minus consequuntur sequi.</p>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    )
}
});
module.exports = MonCarousel;