IL
у меня сторибук это основное отображение всех компонентов и всего и вся, первичный девелопмент контейнеров и мелких компонентов именно там ведется
а потом уже они в боевой проект добавляются
Size: a a a
IL
OA
export interface A {И вот они юзаются в зависимости от ситуации какой компонент я рендерю
component: 'div'
a: string
}
export interface B {
component: 'span'
b: string
}
export type GenericProps = A | BИ вот когда я запрашиваю
export const GenericField: React.FC<GenericFieldProps> = props => {
if (component === 'div') {
return <component>{props.a}</component>
}
return (...)
}
{props.a}оно ругается мол что может быть не найдено a, потому что оно не существует для интерфейса B, хотя я беру его внутри if
export const GenericField: React.FC<GenericFieldProps> = props => {Можно ли как-то по другому, что бы не писать такое полотнище?
if (component === 'div') {
const a = 'a' in props ? a : undefined
return <component>{props.a}</component>
}
return (...)
}
OA
DB
export interface A {И вот они юзаются в зависимости от ситуации какой компонент я рендерю
component: 'div'
a: string
}
export interface B {
component: 'span'
b: string
}
export type GenericProps = A | BИ вот когда я запрашиваю
export const GenericField: React.FC<GenericFieldProps> = props => {
if (component === 'div') {
return <component>{props.a}</component>
}
return (...)
}
{props.a}оно ругается мол что может быть не найдено a, потому что оно не существует для интерфейса B, хотя я беру его внутри if
export const GenericField: React.FC<GenericFieldProps> = props => {Можно ли как-то по другому, что бы не писать такое полотнище?
if (component === 'div') {
const a = 'a' in props ? a : undefined
return <component>{props.a}</component>
}
return (...)
}
OA
OA
DB
OA
DB
OA
EO
export interface A {И вот они юзаются в зависимости от ситуации какой компонент я рендерю
component: 'div'
a: string
}
export interface B {
component: 'span'
b: string
}
export type GenericProps = A | BИ вот когда я запрашиваю
export const GenericField: React.FC<GenericFieldProps> = props => {
if (component === 'div') {
return <component>{props.a}</component>
}
return (...)
}
{props.a}оно ругается мол что может быть не найдено a, потому что оно не существует для интерфейса B, хотя я беру его внутри if
export const GenericField: React.FC<GenericFieldProps> = props => {Можно ли как-то по другому, что бы не писать такое полотнище?
if (component === 'div') {
const a = 'a' in props ? a : undefined
return <component>{props.a}</component>
}
return (...)
}
OA
OA
EO
OA
OA
EO
EO
OA
OA