import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; import autobind from 'autobind-decorator'; import {Cookie} from 'tough-cookie'; import {cookieToString} from '../../common/cookies'; import PromptButton from './base/prompt-button'; @autobind class CookieList extends PureComponent { shouldComponentUpdate (nextProps, nextState) { return nextProps.cookies !== this.props.cookies; } _handleCookieAdd () { const newCookie = new Cookie({ key: 'foo', value: 'bar', domain: this.props.newCookieDomainName, path: '/', secure: false, httpOnly: false }); this.props.onCookieAdd(newCookie); } _handleDeleteCookie (cookie) { this.props.onCookieDelete(cookie); } render () { const { cookies, handleShowModifyCookieModal } = this.props; return (
{cookies.map((cookie, i) => { const cookieString = cookieToString(Cookie.fromJSON(JSON.stringify(cookie))); return ( ); })}
Domain Cookie
handleShowModifyCookieModal(cookie)}> {cookie.domain} handleShowModifyCookieModal(cookie)}> {cookieString} this._handleDeleteCookie(cookie)} title="Delete cookie">
{cookies.length === 0 && (

I couldn't find any cookies for you.

)}
); } } CookieList.propTypes = { onCookieAdd: PropTypes.func.isRequired, onCookieDelete: PropTypes.func.isRequired, cookies: PropTypes.array.isRequired, newCookieDomainName: PropTypes.string.isRequired, handleShowModifyCookieModal: PropTypes.func.isRequired }; export default CookieList;