Named export withRouter()

huangapple go评论63阅读模式
英文:

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);

huangapple
  • 本文由 发表于 2020年1月4日 12:56:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/59588015.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定