0

Based on the solution of my question: setState fires and render method gets hit, but nothing rerenders

Code works if there is NO newline between return and the (, and fails otherwise.

Example:

this works:

render() 
{
        return (
            <View >
                <ListView dataSource={this.state.beers_ds} renderRow={renderRow.bind(this)} />
            </View>
        ); 
} 

But this fails:

render() 
{
        return 
        (
            <View >
                <ListView dataSource={this.state.beers_ds} renderRow={renderRow.bind(this)} />
            </View>
        ); 
} 

Why?

Khalil Khalaf
  • 9,259
  • 11
  • 62
  • 104

2 Answers2

1

Seems like Automatic Semicolon Insertion might be biting you in the butt. I believe javascript will insert a ; at the end of a return statement automatically.

Why doesn't a Javascript return statement work when the return value is on a new line?

Pytth
  • 4,008
  • 24
  • 29
1

As answered here: Javascript function fails to return object when there is a line-break between the return statement and the object?

it's just a matter of JS syntax. Semicolons are automatically added and thus the compiler treats

return
  ( sth )

as

return;
  ( sth )