Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const dataArray = [{key: 0,id: 'A',},{key: 1,id: 'B',},{key: 2,id: 'Z',}]
- // Root Component
- export default class App extends Component {
- render(){
- return (
- <View>
- {this.getSomeText()}
- </
- getSomeText() {
- return dataArray.map( d =>
- <SomeText key={d.key} id={d.id} onLayout={(e) => this.onLayout(e)} />
- )
- }
- onLayout (e, id ) {
- // add these items to array
- // e.nativeEvent.Layout{Width,Height,x,y,id}
- // I can add the e data but the id data never comes through.
- }
- }
- // Child Component
- class SomeText extends Component {
- render() {
- return (
- <Text
- onLayout={this.props.onLayout}
- // onLayout as above this returns the event e but
- // 2. this.props.onLayout() // doesn't return e at all ??
- // 3. () => this.props.onLayout // doesn't work either, why?
- // 4. (e, this.props.key) => this.props.onLayout(this.props.key)
- // 4 doesnt work either
- >Some text</Text>
- )
- }
- }
Add Comment
Please, Sign In to add comment