react-native-modal-dropdown icon indicating copy to clipboard operation
react-native-modal-dropdown copied to clipboard

Encounters a runtime error while using renderRow

Open afshin-hoseini opened this issue 6 years ago • 1 comments

The below snippet faces runtime error, while, it works just fine without renderRow prop.

<Dropdown 
                disabled = {this.state.isLoadingAgents}
                options = {["a","b"]}
                dropdownStyle = {[Styles.agentsDropDown]}
                adjustFrame = {style => {

                    style.width = this.agentDropdownFrameWidth
                    return style
                }}
                renderRow = {this.renderAgentRow.bind(this)}
                >

                <View style={Styles.agentSelectionBox} 
                 onLayout={(event) => this.agentDropdownFrameWidth = event.nativeEvent.layout.width}>

                    {this.state.isLoadingAgents ?
                    
                        <ActivityIndicator color = '#12125A'/> :
                        <Image style={Styles.compassImage}  source = {require('res/Images/Compass/compass.png')}/>
                    }
                    
                    <Text style = {Styles.selectAgentBox_title} > {I18n.t('SelectCity_variantSelection')} </Text>

                </View>

            </Dropdown>

The renderer method

renderAgentRow(item, index, selected) {

    return(<TouchableOpacity> <Text>{item}</Text> </TouchableOpacity>);
}

Error

Raw text cannot be used outside of a <Text> tag. Not rendering string: ' '

afshin-hoseini avatar Mar 31 '18 18:03 afshin-hoseini

Please remove the spaces within the jsx return

return(<TouchableOpacity><Text>{item}</Text></TouchableOpacity>);

sohobloo avatar Apr 02 '18 11:04 sohobloo