简体   繁体   中英

Autosuggest react.js component won't update input style on render

I'm using the react-autosuggest component and I'm styling the border of input part of it with a react inline style which changes based on user input. However, despite the new style being passed to the Autosuggest component every time render() is called, it's not updated. Here's what I have:

 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} /> 
I'm using default values for everything but input. I know the styling works because I gave it a hardcoded gradient and on first page load it displays it just as I want. I also know the value of 'borderstyle' is correct and updated when it's passed into theme , and therefore when theme is passed into the component to be rendered.

这应该在版本3.5.1中修复。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM