diff --git a/demo/src/components/App/components/Example11/Example11.js b/demo/src/components/App/components/Example11/Example11.js index 74eb6db..4abc810 100644 --- a/demo/src/components/App/components/Example11/Example11.js +++ b/demo/src/components/App/components/Example11/Example11.js @@ -1,6 +1,6 @@ import styles from './Example11.less'; -import React, { PropTypes } from 'react'; +import React, { PropTypes, Component } from 'react'; import { connect } from 'react-redux'; import { updateInputValue } from '../../redux'; import Autowhatever from 'Autowhatever'; @@ -62,13 +62,13 @@ const theme = { const exampleId = '11'; const file = `demo/src/components/App/components/Example${exampleId}/Example${exampleId}.js`; -const renderItemsContainer = ({ children, containerProps, data }) => ( +const renderItemsContainer = ({ children, containerProps, query }) => (
{children}
{ - data.query - ? Press Enter to search {data.query} + query + ? Press Enter to search {query} : Powered by react-autowhatever }
@@ -101,36 +101,44 @@ function renderItem(item) { ); } -const Example = props => { - const { value, onChange } = props; - const inputProps = { - placeholder: 'Custom items container', - value, - onChange +class Example extends Component { + static propTypes = { + value: PropTypes.string.isRequired, + onChange: PropTypes.func.isRequired }; - const renderItemsContainerData = { - query: value.trim() + + renderItemsContainer = ({ children, containerProps }) => { + const { value } = this.props; + + return renderItemsContainer({ + children, + containerProps, + query: value.trim() + }); }; - return ( -
- - -
- ); -}; + render() { + const { value, onChange } = this.props; + const inputProps = { + placeholder: 'Custom items container', + value, + onChange + }; -Example.propTypes = { - value: PropTypes.string.isRequired, - onChange: PropTypes.func.isRequired -}; + return ( +
+ + +
+ ); + } +} export default connect(mapStateToProps, mapDispatchToProps)(Example); diff --git a/src/Autowhatever.js b/src/Autowhatever.js index a1f836b..d9d4264 100644 --- a/src/Autowhatever.js +++ b/src/Autowhatever.js @@ -31,7 +31,6 @@ export default class Autowhatever extends Component { multiSection: PropTypes.bool, // Indicates whether a multi section layout should be rendered. renderInputComponent: PropTypes.func, // When specified, it is used to render the input element. renderItemsContainer: PropTypes.func, // Renders the items container. - renderItemsContainerData: PropTypes.object, // Arbitrary data that will be passed to renderItemsContainer() items: PropTypes.array.isRequired, // Array of items or sections to render. renderItem: PropTypes.func, // This function renders a single item. renderItemData: PropTypes.object, // Arbitrary data that will be passed to renderItem() @@ -56,7 +55,6 @@ export default class Autowhatever extends Component { multiSection: false, renderInputComponent: defaultRenderInputComponent, renderItemsContainer: defaultRenderItemsContainer, - renderItemsContainerData: emptyObject, shouldRenderSection: alwaysTrue, renderItem: () => { throw new Error('`renderItem` must be provided'); @@ -305,7 +303,7 @@ export default class Autowhatever extends Component { const { theme } = this; const { id, multiSection, renderInputComponent, renderItemsContainer, - renderItemsContainerData, highlightedSectionIndex, highlightedItemIndex + highlightedSectionIndex, highlightedItemIndex } = this.props; const { isInputFocused } = this.state; const renderedItems = multiSection ? this.renderSections() : this.renderItems(); @@ -349,8 +347,7 @@ export default class Autowhatever extends Component { isOpen && 'itemsContainerOpen' ), ref: this.storeItemsContainerReference - }, - data: renderItemsContainerData + } }); return ( diff --git a/test/render-items-container/Autowhatever.test.js b/test/render-items-container/Autowhatever.test.js index 21c1dd1..1d45206 100644 --- a/test/render-items-container/Autowhatever.test.js +++ b/test/render-items-container/Autowhatever.test.js @@ -30,8 +30,7 @@ describe('Autowhatever with renderItemsContainer', () => { expect(renderItemsContainer).to.have.been.calledOnce; expect(renderItemsContainer).to.be.calledWith({ children: childrenMatcher, - containerProps: containerPropsMatcher, - data: { foo: 'bar' } + containerProps: containerPropsMatcher }); }); }); diff --git a/test/render-items-container/AutowhateverApp.js b/test/render-items-container/AutowhateverApp.js index c1ec3d2..dd40747 100644 --- a/test/render-items-container/AutowhateverApp.js +++ b/test/render-items-container/AutowhateverApp.js @@ -41,7 +41,6 @@ export default class AutowhateverApp extends Component {