Lets say I want to make a library of icons for react+typescript.
As for example lets consider only 2 icons in this library: Apple and Banana.
I want to be able to import them separately as the following:
import { Apple } from 'icons'
class MyComponent extends React.Component {
render() {
return <Apple/>
}
}
Now lets consider a case when each icon has its own set of props:
type Props = {}
class Apple extends React.Component<Props> {
}
type Props = {}
class Banana extends React.Component<Props> {
}
Is there a way I can export these props separately through their components? Like this:
import { Apple } from 'icons'
class MyComponent extends React.Component<Apple.Props> {
render() {
// passing all the props into the apple
return <Apple {...this.props}/>
}
}
namespace Apple { type Props = {} }but I wouldn't recommend it.