Having standard Props interface defined as public makes it possible to reuse the Props definition when creating my own custom version of the component.
For example, when creating my Login Component, I must:
import { FormComponentProps } from 'antd/lib/form/Form'
class Login extends React.Component<{} & FormComponentProps, {}> {
render() {
// some render code
}
}
But following maybe better:
import { FormComponentProps } from 'antd'
class Login extends React.Component<{} & FormComponentProps, {}> {
render() {
// some render code
}
}
At least:
import { FormComponentProps } from 'antd/lib/form'
class Login extends React.Component<{} & FormComponentProps, {}> {
render() {
// some render code
}
}
Just like this TS based UI package does: blueprint
I think the following is good enough:
import { FormComponentProps } from 'antd/lib/form'
class Login extends React.Component<{} & FormComponentProps, {}> {
render() {
// some render code
}
}
I think the first one is better.
Choosing the second way may be because the first one exposed too may interfaces, but these interfaces are very useful when using TypeScript, those who do not use TS simply do not see them.
Many of the frameworks written in TS will expose the interface to the outermost, and do not find any problems.
Of course, the second way can meet the needs. The purpose of this ISSUE is to unify the exposed location of the interface. The current situation is that the location of the interface is unpredictable in the lib/[component name]/
folder.
But I still hope that the first could be adopted, thanks.
Hi, im trying to figure out why is not working for me but, i have this error node_modules/antd/lib/form/index"' has no exported member 'FormComponentProps'.
my workaround was import { FormComponentProps } from 'antd/lib/form/Form';
What im doing wrong ?
@DavidNorena
Do you mean you try this: import { FormComponentProps } from 'antd/lib/form
, but get an error?
of course it's an error, becauseFormComponentProps
doesn't exposed in lib/form
dir now, that's why I submit this issue :)
@newraina ahhhh now I get it ! :D sorry, so meanwhile i'll use import { FormComponentProps } from 'antd/lib/form/Form'; ok ?
@DavidNorena Yes
You can help us for this.
Most helpful comment
I think the first one is better.
Choosing the second way may be because the first one exposed too may interfaces, but these interfaces are very useful when using TypeScript, those who do not use TS simply do not see them.
Many of the frameworks written in TS will expose the interface to the outermost, and do not find any problems.
Of course, the second way can meet the needs. The purpose of this ISSUE is to unify the exposed location of the interface. The current situation is that the location of the interface is unpredictable in the
lib/[component name]/
folder.But I still hope that the first could be adopted, thanks.