简体   繁体   中英

How can I use the props from another file in react?

I have two files: EnhancedTableHEad and OrderDialog. I need the props data from EnhancedTabledHead in my OrderDialog file. How can I achieve that ? My files look like this:

 //OrderDialog.jsx import EnhancedTableHead from '../../Table/EnhancedTableHead'; render() { const {classes, data, onClose, onClick, item, isSelected, rowCount, onSelectAllClick, ...other} = this.props; return () } 
 //EnhancedTableHead.jsx render() { const {onSelectAllClick, order, orderBy, numSelected, rowCount, tableConfiguration} = this.props; return () } EnhancedTableHead.propTypes = { numSelected: PropTypes.number.isRequired, onRequestSort: PropTypes.func.isRequired, order: PropTypes.string.isRequired, orderBy: PropTypes.string.isRequired, rowCount: PropTypes.number.isRequired, onChange: PropTypes.number.isRequired, }; export default EnhancedTableHead; 

Am I understaing this wrong ? For example, I want to use rowCount from EnhancedTableHead in my OrderDialog, but when I do console.log I get undefined. If I do it inside the EnahancedTableHead, console.log will print the right value.

Spread them in OrderDialog. ie

OrderDialog.propTypes = {
 ...EnhancedTableHead.propTypes
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM