Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Raw Text “” must be wrapped in an explicit <text> component #205

Closed
MaxwellGover opened this issue Feb 28, 2017 · 6 comments
Closed
Labels
Milestone

Comments

@MaxwellGover
Copy link

I'm getting this error message when trying to input a year into the title prop

Error Raw Text “” must be wrapped in an explicit <text> component

http://stackoverflow.com/questions/42497037/react-native-error-raw-text-1997-must-be-wrapped-in-an-explicit-text-compone?noredirect=1#comment72144666_42497037

Stackoverflow is saying the error is in the <ListItem /> component which in that case there isn't much I can do since it's a component from this library. Anyone else have this issue?

@binoy14
Copy link
Contributor

binoy14 commented Feb 28, 2017

@MaxwellGover What component is having this issue? Can you provide code sample so we can debug it.

@MaxwellGover
Copy link
Author

The <ListItem /> component. In my renderRow function it gives me an error,

Error: Raw text "1997" must be wrapped in an explicit <text> component

Also says invalid prop type being passed to 'title'

import React, { PropTypes, Component } from 'react'
import { View, Text, ListView, StyleSheet } from 'react-native'
import { connect } from 'react-redux'
import { List, ListItem } from 'react-native-elements'
import NavigationBar from 'react-native-navbar'
import { storeUserYear, getSchedule } from '~/redux/modules/data'

class Year extends Component {
	static propTypes = {
		dispatch: PropTypes.func.isRequired,
		navigator: PropTypes.object.isRequired,
		userCarModel: PropTypes.object.isRequired
	}
	constructor (props) {
		super(props)
		this.ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2 })
		this.state = {
			dataSource: this.ds.cloneWithRows(this.props.userCarModel.years)
		}
	}
	renderRow = (year) => { 
		return (
			<ListItem 
				key={year.id} 
				title={year.year} 
				onPress={() => {
						this.props.dispatch(storeUserYear(year))
						this.props.dispatch(getSchedule(year.id))
						this.props.navigator.push({
							schedule: true
						})
					}
				}
				underlayColor='#eceeef'
			/>
		) 
	}
	render () {
		console.log(this.props.userCarModel)
		return (
			<View style={{flex: 1}}>
				<NavigationBar 
					title={{title: 'Year'}}
					tintColor='#fff'
					style={{borderColor: '#e80d2d'}}
				/>
				<View style={styles.helpTextContainer}>
					<Text style={{marginLeft: 10}}>
						Select the year of your vehicle
					</Text>
				</View>
				<List containerStyle={{flex: 1, marginTop: 0}}>
					<ListView 
						renderRow={model => this.renderRow(model)}
						dataSource={this.state.dataSource}
					/>
				</List>
			</View>
		)
	}
}

function mapStateToProps ({data}) {
	return {
		userCarModel: data.userCarModel
	}
}

export default connect(mapStateToProps)(Year)

const styles = StyleSheet.create({
	helpTextContainer: {
		height: 30,
		backgroundColor: '#eceeef',
		justifyContent: 'center'
	}
})

@MaxwellGover
Copy link
Author

@binoy14 Any updates on this issue?

@binoy14
Copy link
Contributor

binoy14 commented Mar 1, 2017

@MaxwellGover I know the root cause of the issue and will fix in the next release. In the mean time any number can be passed in using this

title="`${year.year}`" 

or

title={<Text>{year.year}</Text>}

This won't be the case in future. Thanks for reporting

@binoy14 binoy14 added this to the 0.10.0 milestone Mar 1, 2017
binoy14 added a commit that referenced this issue Mar 3, 2017
@MaxwellGover
Copy link
Author

@binoy14 Ok cool. Thanks. Great library btw.

@binoy14
Copy link
Contributor

binoy14 commented Mar 3, 2017

@MaxwellGover Thank you for reporting. The issue is in works. #207 is almost ready to get merged

@binoy14 binoy14 closed this as completed in 81448ac Mar 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants