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

Warning when using the SectionList sample from the tutorial #16231

Closed
gabrielweyer opened this issue Oct 6, 2017 · 0 comments
Closed

Warning when using the SectionList sample from the tutorial #16231

gabrielweyer opened this issue Oct 6, 2017 · 0 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@gabrielweyer
Copy link
Contributor

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

I'm not using react-native directly, instead I'm using create-react-native-app which I installed via npm.

Environment:

  • OS: Win 10 Pro Version 1703 (OS Build 15063.608)
  • Node: 6.9.1
  • Yarn: not installed
  • npm: 4.6.1
  • Watchman: not installed (as far as I know)
  • Xcode: not installed
  • Android Studio: not installed

Packages: (wanted => installed)

Not too sure about this one, ran npm list --depth=0

+-- expo@21.0.2
+-- jest-expo@21.0.2
+-- react@16.0.0-alpha.12
+-- react-native@0.48.4
+-- react-native-scripts@1.5.0
`-- react-test-renderer@16.0.0-alpha.12

npm ERR! peer dep missing: react@>=15.4.0, required by react-native-branch@2.0.0-beta.3
npm ERR! peer dep missing: react@> 15.0.0, required by react-native-gesture-handler@1.0.0-alpha.22

Target Platform:

Nexus 5 - Android 6.0.1

Steps to Reproduce

  1. Go to the Using List Views tutorial
  2. Copy the sample from the SectionList
  3. Run the app

Expected Behavior

I expected to see no warning in the app.

Actual Behavior

A warning was displayed at the bottom of the screen:

image

It also appears in the PowerShell console:

6:37:49 PM: VirtualizedList: missing keys for items, make sure to specify a key property on each item or provide a custom keyExtractor.
- node_modules\expo\src\Logs.js:187:24 in newConsoleFunc
- node_modules\react-native\Libraries\ReactNative\YellowBox.js:76:15 in warn
- ... 77 more stack frames from framework internals

Reproducible Demo

import React, { Component } from 'react';
import { AppRegistry, SectionList, StyleSheet, Text, View } from 'react-native';

export default class SectionListBasics extends Component {
  render() {
    return (
      <View style={styles.container}>
        <SectionList
          sections={[
            {title: 'D', data: ['Devin']},
            {title: 'J', data: ['Jackson', 'James', 'Jillian', 'Jimmy', 'Joel', 'John', 'Julie']},
          ]}
          renderItem={({item}) => <Text style={styles.item}>{item}</Text>}
          renderSectionHeader={({section}) => <Text style={styles.sectionHeader}>{section.title}</Text>}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
   flex: 1,
   paddingTop: 22
  },
  sectionHeader: {
    paddingTop: 2,
    paddingLeft: 10,
    paddingRight: 10,
    paddingBottom: 2,
    fontSize: 14,
    fontWeight: 'bold',
    backgroundColor: 'rgba(247,247,247,1.0)',
  },
  item: {
    padding: 10,
    fontSize: 18,
    height: 44,
  },
})

// skip this line if using Create React Native App
AppRegistry.registerComponent('AwesomeProject', () => SectionListBasics);
facebook-github-bot pushed a commit that referenced this issue Oct 7, 2017
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

I wanted to fix issue #16231 - the warning is not displayed anymore:

![image](https://user-images.githubusercontent.com/2101647/31268083-7e2e0ddc-aac6-11e7-966b-b1e9ffa6cfa8.png)
Closes #16232

Differential Revision: D6005386

Pulled By: hramos

fbshipit-source-id: 33961ee7cd708c424c2665a38dc5e733f1ea2204
@hramos hramos closed this as completed Oct 10, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Oct 10, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants