From 805829be780d230857927cb5a52783b77f0b71e3 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Sat, 8 Jul 2017 13:29:25 +0900 Subject: [PATCH] Make InfoButton component stateless --- browser/main/Detail/InfoButton.js | 32 +++++++---------------- browser/main/Detail/MarkdownNoteDetail.js | 9 ++++++- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/browser/main/Detail/InfoButton.js b/browser/main/Detail/InfoButton.js index 1c1e0c11..24498880 100644 --- a/browser/main/Detail/InfoButton.js +++ b/browser/main/Detail/InfoButton.js @@ -2,29 +2,15 @@ import React, { PropTypes } from 'react' import CSSModules from 'browser/lib/CSSModules' import styles from './InfoButton.styl' -class InfoButton extends React.Component { - constructor (props) { - super(props) - - this.handleInfoButtonClick = this.handleInfoButtonClick.bind(this) - } - - handleInfoButtonClick (e) { - e.preventDefault() - const infoPanel= document.querySelector('.infoPanel') - infoPanel.style.display = display === 'none' ? 'inline' : 'none' - } - - render () { - return ( - - ) - } -} +const InfoButton = ({ + onClick +}) => ( + +) InfoButton.propTypes = { } diff --git a/browser/main/Detail/MarkdownNoteDetail.js b/browser/main/Detail/MarkdownNoteDetail.js index 195c36dc..559262b2 100644 --- a/browser/main/Detail/MarkdownNoteDetail.js +++ b/browser/main/Detail/MarkdownNoteDetail.js @@ -232,6 +232,11 @@ class MarkdownNoteDetail extends React.Component { this.focus() } + handleInfoButtonClick (e) { + const infoPanel= document.querySelector('.infoPanel') + infoPanel.style.display = display === 'none' ? 'inline' : 'none' + } + render () { let { data, config, location } = this.props let { note } = this.state @@ -303,7 +308,9 @@ class MarkdownNoteDetail extends React.Component { > - +