我正在使用react-autosuggest component并且我使用反应内联样式设置其输入部分的边框样式,该内联样式根据用户输入而变化。但是,尽管每次调用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
传递到要渲染的组件时。
答案 0 :(得分:0)
这应该在3.5.1版中修复。