pnv
pnv

Reputation: 3135

Getting false warning on 'unknown props' in react

I've following code, I've created a dumb component,

const editViewTable = ({ headerData, bodyData }) =>
(
  <div>.....</div>
)

editViewTable.propTypes = {
  headerData: React.PropTypes.arrayOf(React.PropTypes.string),
  bodyData: React.PropTypes.arrayOf(React.PropTypes.object),
};

export default editViewTable;

And an intelligent one,

import * as actions from './actions';
import React from 'react';
import { connect } from 'react-redux';
import { getOnehopProducts } from './reducers';
import editViewTable from '../common/editViewTable/component';

const mapStateToProps = (state, params) => {
  return {
    headerData: ['name', 'category', 'merchant'],
    bodyData: getOnehopProducts(state)
  };
}

class ProductList extends React.Component {
  componentDidMount() {
    this.fetchData();
  }

    fetchData() {
        const { fetchProducts } = this.props;
        fetchProducts({});
    }

  render(){
    const { headerData, bodyData } = this.props;
    return <editViewTable headerData={headerData} bodyData={bodyData} />;
  }
}


ProductList = connect(
  mapStateToProps,
  actions
)(ProductList);

export default ProductList;

Whenever I'm rendering the component, I'm getting the error Warning: Unknown props 'headerData', 'bodyData' on <editViewTable> tag. Remove these props from the element.

I'm unable to find, what's causing the problem. I'm clearly not passing extra props, so what's causing the error. I'm pretty much newbie to react.

I'm using react-material.

Upvotes: 0

Views: 177

Answers (1)

pnv
pnv

Reputation: 3135

After renaming editViewTable to EditViewTable, this warning has gone, and everything is working fine and dandy.

Upvotes: 1

Related Questions