React Native render function throws error

Ranjith Srikanth

Here is my render function of react native. if i put listview it works. if i put touchablehighlight it works. but, if it put both it doesn't work. need help.

render: function() {
    return (
      /* ListView wraps ScrollView and so takes on its properties.
       With that in mind you can use the ScrollView's contentContainerStyle prop to style the items.*/
        <ListView
          contentContainerStyle={styles.list}
          dataSource={this.state.dataSource}
          renderRow={this._renderRow}/>
        <TouchableHighlight onPress={() => this._pressRow(rowID)} underlayColor="transparent">
        </TouchableHighlight>
    );
},

what is wrong here? need both components to work.

bozzmob

You can't have 2 tags that you can return. You should wrap it inside a <View> </View> tag. This way you can abstract multiple components that you need in the page.

render: function() {
    return (
      /* ListView wraps ScrollView and so takes on its properties.
       With that in mind you can use the ScrollView's contentContainerStyle prop to style the items.*/
      <View>  
        <ListView
          contentContainerStyle={styles.list}
          dataSource={this.state.dataSource}
          renderRow={this._renderRow}/>
        <TouchableHighlight onPress={() => this._pressRow(rowID)} underlayColor="transparent">
        </TouchableHighlight>
      </View>
    );
},

Hope it helps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

React Native render function gives an error : Unexpected token

From Dev

React error: TypeError: render is not a function

From Dev

React Native upgrade to 0.22.2 throws NetInfo error

From Dev

Skipping Views in React Native render function

From Dev

React Native call a function in a render method

From Dev

How to render components using function in React Native

From Dev

react native navigator render method error

From Dev

react native : How to fix the error - Passing an inline function will cause the component state to be lost on re-render?

From Dev

react native : How to fix the error - Passing an inline function will cause the component state to be lost on re-render?

From Dev

React Native undefined is not a function error

From Dev

React native typescript throws error when running jest test command

From Dev

Render Content Dynamically from an array map function in React Native

From Dev

How do I render a function which contain a view in react native?

From Dev

React Native FlatList - Calling A Function In The Render Method Which Returns A Component

From Dev

Render HTML in React Native

From Dev

React Native staggered render

From Dev

React Native View Render

From Dev

React Native: Render on Fetch

From Dev

how to render objects in react native?

From Dev

react native render only part

From Dev

setState not causing a render React Native

From Dev

React Native : FlatList does not render

From Dev

Error with React render

From Dev

Error with React render

From Dev

REACT - Error to render component

From Dev

React Native fetch throws error when posting multipart/form-data

From Dev

React Native / React - refactoring prop before render()

From Dev

Function returning an object throws error

From Dev

Codeigniter search function throws an error

Related Related

  1. 1

    React Native render function gives an error : Unexpected token

  2. 2

    React error: TypeError: render is not a function

  3. 3

    React Native upgrade to 0.22.2 throws NetInfo error

  4. 4

    Skipping Views in React Native render function

  5. 5

    React Native call a function in a render method

  6. 6

    How to render components using function in React Native

  7. 7

    react native navigator render method error

  8. 8

    react native : How to fix the error - Passing an inline function will cause the component state to be lost on re-render?

  9. 9

    react native : How to fix the error - Passing an inline function will cause the component state to be lost on re-render?

  10. 10

    React Native undefined is not a function error

  11. 11

    React native typescript throws error when running jest test command

  12. 12

    Render Content Dynamically from an array map function in React Native

  13. 13

    How do I render a function which contain a view in react native?

  14. 14

    React Native FlatList - Calling A Function In The Render Method Which Returns A Component

  15. 15

    Render HTML in React Native

  16. 16

    React Native staggered render

  17. 17

    React Native View Render

  18. 18

    React Native: Render on Fetch

  19. 19

    how to render objects in react native?

  20. 20

    react native render only part

  21. 21

    setState not causing a render React Native

  22. 22

    React Native : FlatList does not render

  23. 23

    Error with React render

  24. 24

    Error with React render

  25. 25

    REACT - Error to render component

  26. 26

    React Native fetch throws error when posting multipart/form-data

  27. 27

    React Native / React - refactoring prop before render()

  28. 28

    Function returning an object throws error

  29. 29

    Codeigniter search function throws an error

HotTag

Archive