[英]Autosuggest react.js component won't update input style on render
我正在使用react-autosuggest組件,並使用基於用戶輸入而變化的react內聯樣式來設置其輸入部分的邊框樣式。 但是,盡管每次調用render()
都會將新樣式傳遞給Autosuggest組件,但它不會更新。 這是我所擁有的:
var borderStyle; if (gradient) { borderStyle = { borderImageSlice: 1, borderImage: '-webkit-linear-gradient(right, '+borderColour2+' 0%, '+borderColour2+' 40%, '+borderColour1+' 60%, '+borderColour1+' 100%) 1' }; } else { borderStyle = { 'borderColor': borderColour1 }; } var theme = { container: 'react-autosuggest__container', containerOpen: 'react-autosuggest__container--open', input: borderStyle, suggestionsContainer: 'react-autosuggest__suggestions-container', suggestion: 'react-autosuggest__suggestion', suggestionFocused: 'react-autosuggest__suggestion--focused', sectionContainer: 'react-autosuggest__section-container', sectionTitle: 'react-autosuggest__section-title', sectionSuggestionsContainer: 'react-autosuggest__section-suggestions-container' }; <Autosuggest suggestions={suggestions} theme={theme} onSuggestionsUpdateRequested={this.onSuggestionsUpdateRequested} getSuggestionValue={getSuggestionValue} renderSuggestion={renderSuggestion} inputProps={inputProps} ref={this.saveInput} onSuggestionSelected={this.selectCard} />
theme
時是正確的,並且會更新,因此在將theme
傳遞給要渲染的組件時也是如此。
這應該在版本3.5.1中修復。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.