When I export the Room component with connect, in the App component, the ref of the Room component setting does not work normally. If the connect is removed, it works normally. The following is a part of the main code demonstration.``
App.tsx
.....
class App extends React.Component<I_PROPS, I_STATE>{
private refRoom: React.RefObject<Room_T>;
constructor(props:any){
super(props);
this.refRoom = createRef();
}
render() {
return (
<Provider store={STORE}>
<Room ref={this.refRoom} />
</Provider>
)
}
}
export default App;
``
<Room ref={this.refRoom} />
Error: Type 'RefObject<Room_T>' is not assignable to type 'string | ((instance: typeof Room_T | null) => void) | RefObject | null | undefined'. Type 'RefObject<Room_T>' is not assignable to type 'RefObject'. Types of property 'current' are incompatible. Type 'Room_T | null' is not assignable to type 'typeof Room_T | null'. Property 'prototype' is missing in type 'Room_T' but required in type 'typeof Room_T'
Room.tsx
....
import { connect } from 'react-redux';
....
export class Room_T extends React.Component {
render() {
return(
....
)
}
}
export default connect(mapStateToProps, null, null, {
forwardRef: true
})(Room_T)
dependencies
react = "16.13.1"
react-redux = "7.2.1"
redux = "4.0.5"
devDependencies
@types/react = "16.9.26"
@types/react-redux = "7.1.8"
typescript = "3.9.2"