import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { Row, Input } from 'antd'; import constants from '../../constants/variable.js'; const wordList = constants.MOCK_SOURCE; const Search = Input.Search; class MockList extends Component { static propTypes = { click: PropTypes.func, clickValue: PropTypes.string }; constructor(props) { super(props); this.state = { filter: '', list: [] }; } componentDidMount() { this.setState({ list: wordList }); } onFilter = e => { const list = wordList.filter(item => { return item.mock.indexOf(e.target.value) !== -1; }); this.setState({ filter: e.target.value, list: list }); }; render() { const { list, filter } = this.state; const { click, clickValue } = this.props; return (
{list.map((item, index) => { return ( click(item.mock)} > {item.mock} ); })}
); } } export default MockList;