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

Some strange rendering behavior. #277

Open
MaxMillington opened this issue Oct 15, 2018 · 1 comment
Open

Some strange rendering behavior. #277

MaxMillington opened this issue Oct 15, 2018 · 1 comment

Comments

@MaxMillington
Copy link

MaxMillington commented Oct 15, 2018

  • 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!

@dmikey
Copy link
Collaborator

dmikey commented Oct 16, 2018

Thanks, will take a look at these right away!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants