Skip to content

Some strange rendering behavior.  #277

@MaxMillington

Description

@MaxMillington
  • syr-cli version: latest
  • syr version: latest

Relevant code.

class MyComponent extends Component {
  constructor(props) {
    super(props)

    this.state = { data: null }
  }

  componentDidMount() {
    this.getData()
  }

  getData() {
    console.log('getting data', fakeData.data)
    this.setState({ data: fakeData.data })
  }

  render() {
    console.log('hey rendering', this.state.data)
    if (!this.state.data) {
      return (
        <View style={styles.view}>
          <Text style={styles.text}>There aint no data in this app!</Text>
        </View>
      );
    }

    return (
      <View style={styles.view}>
        <Text style={styles.text}>Welcome to the sweet shoplist app with data!</Text>
      </View>
    );
  }
}

What you did:

changed the code to:

class MyComponent extends Component {
  constructor(props) {
    super(props)

    this.state = { data: null }
  }

  componentDidMount() {
    this.getData()
  }

  getData() {
    console.log('getting data', fakeData.data)
    this.setState({ data: fakeData.data })
  }

  render() {
    console.log('hey rendering', this.state.data)
    return (
      <View style={styles.view}>
        <Text style={styles.text}>{
          this.state.data ? 'Welcome to the sweet shoplist app with data!' : 'No Data Here!'
        }</Text>
      </View>
    );
  }
}

What happened: The first chunk of code gets an update not found error from Syr. Meaning that the when the app gets data and runs SetState, it does not rerender. The second chunk does rerender, but produces the following:

screen shot 2018-10-12 at 2 15 03 pm

Problem description:

Would be great if these worked!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions