admin管理员组文章数量:1400108
Running into this strange error using @react-spring/web
import { PropsWithChildren, ReactNode } from 'react'
import { useSpring, animated } from '@react-spring/web'
import useMeasure from 'react-use-measure'
export interface ExpandableCardProps {
open: boolean
content: ReactNode
}
export function ExpandableCard({ open, content, children, ...rest }: PropsWithChildren<ExpandableCardProps>) {
const [ref, { height }] = useMeasure()
const slideAnimation = useSpring({
height: open ? height : 0,
config: {
tension: 500,
friction: 50,
},
})
return (
<div className="shadow-md flex flex-col rounded-size-6 bg-[var(--bg-secondary)] overflow-hidden" {...rest}>
<div className="rounded-size-6 bg-[var(--bg-primary)] shadow-xs">{children}</div>
Type '{ children: Element; style: { overflow: "hidden"; height: SpringValue<number>; }; }' is not assignable to type 'IntrinsicAttributes & AnimatedProps<{ style?: { accentColor?: AccentColor | undefined; alignContent?: AlignContent | undefined; alignItems?: AlignItems | undefined; ... 841 more ...; matrix3d?: readonly [...] | undefined; } | undefined; }> & { ...; }'.
Property 'children' does not exist on type 'IntrinsicAttributes & AnimatedProps<{ style?: { accentColor?: AccentColor | undefined; alignContent?: AlignContent | undefined; alignItems?: AlignItems | undefined; ... 841 more ...; matrix3d?: readonly [...] | undefined; } | undefined; }> & { ...; }'
<animated.div style={{ ...slideAnimation, overflow: 'hidden' }}>
<div ref={ref} className="rounded-b-size-6">
{content}
</div>
</animated.div>
</div>
)
}
Everytime I try to import animated
or a
I get the same issue
Running into this strange error using @react-spring/web
import { PropsWithChildren, ReactNode } from 'react'
import { useSpring, animated } from '@react-spring/web'
import useMeasure from 'react-use-measure'
export interface ExpandableCardProps {
open: boolean
content: ReactNode
}
export function ExpandableCard({ open, content, children, ...rest }: PropsWithChildren<ExpandableCardProps>) {
const [ref, { height }] = useMeasure()
const slideAnimation = useSpring({
height: open ? height : 0,
config: {
tension: 500,
friction: 50,
},
})
return (
<div className="shadow-md flex flex-col rounded-size-6 bg-[var(--bg-secondary)] overflow-hidden" {...rest}>
<div className="rounded-size-6 bg-[var(--bg-primary)] shadow-xs">{children}</div>
Type '{ children: Element; style: { overflow: "hidden"; height: SpringValue<number>; }; }' is not assignable to type 'IntrinsicAttributes & AnimatedProps<{ style?: { accentColor?: AccentColor | undefined; alignContent?: AlignContent | undefined; alignItems?: AlignItems | undefined; ... 841 more ...; matrix3d?: readonly [...] | undefined; } | undefined; }> & { ...; }'.
Property 'children' does not exist on type 'IntrinsicAttributes & AnimatedProps<{ style?: { accentColor?: AccentColor | undefined; alignContent?: AlignContent | undefined; alignItems?: AlignItems | undefined; ... 841 more ...; matrix3d?: readonly [...] | undefined; } | undefined; }> & { ...; }'
<animated.div style={{ ...slideAnimation, overflow: 'hidden' }}>
<div ref={ref} className="rounded-b-size-6">
{content}
</div>
</animated.div>
</div>
)
}
Everytime I try to import animated
or a
I get the same issue
1 Answer
Reset to default 1This is a reported bug in @react-spring/web that is still open at the time of writing.
Deftunk recommends creating a custom.d.ts
file and overriding the type:
import reactSpring from "@react-spring/web";
declare module "@react-spring/web" {
const animated = {
children: React.ReactNode,
...reactSpring.animated,
};
}
本文标签: javascriptreactspringwebchildren not definedStack Overflow
版权声明:本文标题:javascript - @react-springweb + children not defined - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744194711a2594683.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
animated.div
. Whether or not that's actually true is a question for their API docs. – Jared Smith Commented Mar 25 at 13:36