簡體   English   中英

Autosuggest react.js組件不會在渲染時更新輸入樣式

[英]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} /> 
我正在使用除輸入以外的所有內容的默認值。 我知道樣式有效,因為我給了它一個硬編碼的漸變,並在第一頁加載時按我的意願顯示它。 我也知道'borderstyle'的值在傳遞給theme時是正確的,並且會更新,因此在將theme傳遞給要渲染的組件時也是如此。

這應該在版本3.5.1中修復。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM