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

how can I pass my remove function with a parameter inside InpuTime?

$
0
0

I'm trying to pass a remove function into the map with a parameter, but it's like I'm not using my function. What would be the correct way to call ''remove(i)'' inside InputTime in onRemove?

Component    static propTypes = {        values: PropTypes.array.isRequired,        remove: PropTypes.func.isRequired    };       render() {    const {values, remove} = this.props;    if(!values) return null;    return(<>        {values.map((hour, i) => (<Container scope={getField(i)} key={i}><InputTime              time={hour}              onRemove={() => remove(i)}              {...this.props}            /></Container>        ))}  </>    )  }}// another class  handlerRemove(){    ...  }return(<Component values={values} remove={() => this.handlerRemove()} />)

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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