saleel / react-native-super-grid

Responsive Grid View for React Native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed prop type: Invalid prop `style` of type `number` supplied to `FlatGrid`, expected `object`.

siarheipashkevich opened this issue · comments

Hi all.

I have the styles.js file:

import { StyleSheet } from 'react-native';

export default StyleSheet.create({
  gridView: {
    paddingTop: 0,
  },
});

And I try use this style for FlatGrid:

<FlatGrid
  ref={flatGridRef}
  data={data}
  style={styles.gridView}
  renderItem={renderItem}
  keyExtractor={getGridItemUniqueKey}
/>

But I'm getting en error:

Warning: Failed prop type: Invalid prop `style` of type `number` supplied to `FlatGrid`, expected `object`.

Could you please extend style prop for getting styles?

style: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),

Extending the style prop to include number wont solve the problem I believe. Why is the style passed a number? It should be an object.

@saleel you can try my example with two files one index.js and another styles.js. If extend style as I mentioned above then it works.

Yes, since you are importing the stylesheet from a different file, it will a number mapped by RN internally.

When you change style prop like you had, are you able to see the desired style changes in the UI as well? If that is the case, you can create a PR for the same.