英文:
Named export withRouter()
问题
我想导出组件withRouter()
,但我需要它的名称不带默认值。
export { withRouter } from 'react-router-dom';
我尝试过以下方式:
export { TopNav } from 'react-router-dom';
语法错误信息来自于代码检查工具是...
禁止使用默认导出(no-default-export)tslint(1)是否有一种方法来命名导出项?
英文:
I want to export the components withRouter()
but I need it to be named without the default
export default withRouter(TopNav);
I've tried
export {TopNav} withRouter(TopNav);
The error I get from the linter is...
Use of default exports is forbidden (no-default-export)tslint(1) is there a way name the export?
答案1
得分: 7
命名导出必须声明,这样你就可以像这样做:
export const TopNavWithRouter = withRouter(TopNav);
英文:
Named exports have to be declared so you can do something like this:
export const TopNavWithRouter = withRouter(TopNav);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论