import React from 'react'; import PropTypes from 'prop-types'; import Page from '../PageList/Page'; import loggerFactory from '~/utils/logger'; const logger = loggerFactory('growi:searchResultList'); class SearchResultList extends React.Component { render() { return this.props.pages.map((page) => { // Add prefix 'id_' in pageId, because scrollspy of bootstrap doesn't work when the first letter of id attr of target component is numeral. const pageId = `#${page._id}`; return (
  • { try { if (this.props.onClickInvoked == null) { throw new Error('onClickInvoked is null') } this.props.onClickInvoked(page._id); } catch (error) { logger.error(error); } }} >
    {/* TODO: remove dummy snippet and adjust style */}
    {page.snippet}
    {this.props.deletionMode && (
    { try { if (this.props.onChangeInvoked == null) { throw new Error('onChnageInvoked is null') } return this.props.onChangeInvoked(page); } catch (error) { logger.error(error); } }} />
    )}
  • ); }); } } SearchResultList.propTypes = { pages: PropTypes.array.isRequired, deletionMode: PropTypes.bool.isRequired, selectedPages: PropTypes.array.isRequired, onClickInvoked: PropTypes.func, onChangeInvoked: PropTypes.func, }; export default SearchResultList;