In the tutorial I see this
import React, { Component, PropTypes } from 'react'
class PureInput extends Component {
shouldComponentUpdate(nextProps) {
return this.props.field !== nextProps.field
}
render() {
const { field, ...rest } = this.props
return <input {...field} {...rest}/>
}
}
PureInput.propTypes = {
field: PropTypes.object.isRequired
}
export default PureInput
I have try as Typescript in my project like this
import * as React from 'react'
interface Props {
field: any
}
export class PureInput extends React.Component<Props, void> {
shouldComponentUpdate(nextProps) {
return this.props.field !== nextProps.field
}
render() {
const { field, ...rest } = this.props
return (<input {...field} {...rest} />)
}
}
And it warn an errors on ...rest so what should I do ?, not sure that I should make the Props interface to dictionary by add code like [rest:string]:any into it or not, I have tried and it is not work
const { field, ...rest } = this.props
This isn't support yet.
https://github.com/Microsoft/TypeScript/issues/2103
Follow along for updates 🌹