diff --git a/docs/storybook/1-components/Image/ImageScreen.js b/docs/storybook/1-components/Image/ImageScreen.js index 27fd53f6..53d560da 100644 --- a/docs/storybook/1-components/Image/ImageScreen.js +++ b/docs/storybook/1-components/Image/ImageScreen.js @@ -5,7 +5,6 @@ */ import React from 'react'; -import PropChildren from './examples/PropChildren'; import PropDefaultSource from './examples/PropDefaultSource'; import PropDraggable from './examples/PropDraggable'; import PropOnError from './examples/PropOnError'; @@ -35,15 +34,6 @@ const ImageScreen = () => (
- - }} - /> - + {loader} - {loader} - + /> {this.state.message && {this.state.message}} ); diff --git a/docs/storybook/1-components/Image/examples/PropChildren.js b/docs/storybook/1-components/Image/examples/PropChildren.js index a496ecbe..c2f80308 100644 --- a/docs/storybook/1-components/Image/examples/PropChildren.js +++ b/docs/storybook/1-components/Image/examples/PropChildren.js @@ -4,12 +4,12 @@ import sources from '../sources'; import React from 'react'; -import { Image, StyleSheet, Text } from 'react-native'; +import { ImageBackground, StyleSheet, Text } from 'react-native'; const ImageChildrenExample = () => ( - + Child content - + ); const styles = StyleSheet.create({ diff --git a/src/components/Image/__tests__/index-test.js b/src/components/Image/__tests__/index-test.js index 9ee0f447..c29058b2 100644 --- a/src/components/Image/__tests__/index-test.js +++ b/src/components/Image/__tests__/index-test.js @@ -33,12 +33,6 @@ describe('components/Image', () => { expect(component.prop('accessible')).toBe(false); }); - test('prop "children"', () => { - const children =
; - const component = shallow(); - expect(component.find('.unique').length).toBe(1); - }); - describe('prop "defaultSource"', () => { test('sets background image when value is an object', () => { const defaultSource = { uri: 'https://google.com/favicon.ico' }; diff --git a/src/components/Image/index.js b/src/components/Image/index.js index 1fc236fe..d030cb18 100644 --- a/src/components/Image/index.js +++ b/src/components/Image/index.js @@ -96,7 +96,6 @@ class Image extends Component<*, State> { static propTypes = { ...ViewPropTypes, - children: any, defaultSource: ImageSourcePropType, draggable: bool, onError: func, @@ -176,7 +175,6 @@ class Image extends Component<*, State> { const { accessibilityLabel, accessible, - children, defaultSource, draggable, onLayout, @@ -221,6 +219,16 @@ class Image extends Component<*, State> { }) : null; + if (process.env.NODE_ENV !== 'production') { + if (this.props.src) { + console.warn('The component requires a `source` property rather than `src`.'); + } + + if (this.props.children) { + throw new Error('The component cannot contain children. If you want to render content on top of the image, consider using the component or absolute positioning.'); + } + } + return ( { testID={testID} > {hiddenImage} - {children} ); }