summaryrefslogtreecommitdiffstats
path: root/webapp/components/suggestion/suggestion.jsx
blob: 8547d50d065f1fb5f06bb845139fac3247b3523a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import React from 'react';

export default class Suggestion extends React.Component {
    static get propTypes() {
        return {
            item: React.PropTypes.object.isRequired,
            term: React.PropTypes.string.isRequired,
            matchedPretext: React.PropTypes.string.isRequired,
            isSelection: React.PropTypes.bool,
            onClick: React.PropTypes.func
        };
    }

    constructor(props) {
        super(props);

        this.handleClick = this.handleClick.bind(this);
    }

    handleClick(e) {
        e.preventDefault();

        this.props.onClick(this.props.term, this.props.matchedPretext);
    }
}