मैं React के साथ टाइपस्क्रिप्ट का उपयोग कर रहा हूं। मुझे यह समझने में परेशानी हो रही है कि रेफरी द्वारा संदर्भित प्रतिक्रिया नोड्स के संबंध में स्टैटिक टाइपिंग और इंटेलीसेंस प्राप्त करने के लिए रेफरी का उपयोग कैसे करें। मेरा कोड इस प्रकार है।
import * as React from 'react';
interface AppState {
count: number;
}
interface AppProps {
steps: number;
}
interface AppRefs {
stepInput: HTMLInputElement;
}
export default class TestApp extends React.Component<AppProps, AppState> {
constructor(props: AppProps) {
super(props);
this.state = {
count: 0
};
}
incrementCounter() {
this.setState({count: this.state.count + 1});
}
render() {
return (
<div>
<h1>Hello World</h1>
<input type="text" ref="stepInput" />
<button onClick={() => this.incrementCounter()}>Increment</button>
Count : {this.state.count}
</div>
);
}}
refsवर्ग विशेषता के साथ नीचे दिए गए उदाहरणों को आगामी प्रतिक्रिया संस्करणों में पदावनत किया जाएगा।