Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6314

How can i convert node props in JS Code to TS Code?

$
0
0
    const SliderContainer = ({node, time}) => (<Container>            {node.map(program=>(<Slide                 key={program.id}                 id={program.id}                 title={program.title? trimText(program.title,8): trimText(program.name, 8)}                 overview={trimText(program.overview, 50)}                votes={program.vote_average}                backgroundImage={program.backdrop_path}                poster={program.poster_path}                />            ))}</Container>)

i wanna convert this JS Code to TS Code, so i tried

interface NodeProps {    node: Nodes    time: string}interface Nodes {    reactNode :{        id: number        title?: string        name?: string        overview: string        vote_average: number        backdrop_path: string        poster_path: string    }}const SliderContainer = ({node, time}: NodeProps) => (<Container><Swiper controlsEnabled={false} loop timeout={time}>            {node.map(program => (<Slide                 key={program.id}                 id={program.id}                 title={program.title? trimText(program.title,8): trimText(program.name, 8)}                 overview={trimText(program.overview, 50)}                votes={program.vote_average}                backgroundImage={program.backdrop_path}                poster={program.poster_path}                />            ))}</Swiper></Container>)

in the JS Code, node in Parameter is Proptypes.node. and contains id, title, vote...,etc. ( these things from movie API).and in result, the node.map() function is not work and i am searching many times how convert that code but i don't know.help me Please...


Viewing all articles
Browse latest Browse all 6314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>