React = require 'react' {Actions} = require 'inbox-exports' _ = require 'underscore-plus' SearchSuggestionStore = require './search-suggestion-store' module.exports = SearchBar = React.createClass getInitialState: -> constants: SearchSuggestionStore.searchConstants() showing: false componentDidMount: -> @unsubscribe = SearchSuggestionStore.listen @_onStoreChange componentWillUnmount: -> @unsubscribe() render: -> containerClass = if @state.showing then "showing" else "hidden"
From:
Subject:
_onValueChange: (event) -> constants = SearchSuggestionStore.searchConstants() constants[event.target.name] = event.target.value Actions.searchConstantsChanged(constants) _onStoreChange: -> @setState showing: SearchSuggestionStore.query()?.length > 0 constants: SearchSuggestionStore.searchConstants()