react-window-size
react-window-size copied to clipboard
React warning when function component is used
Apparently the line 46 results in a React warning when the comp is a function component.
ref={c => { this.wrappedInstance = c; }}
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
I Temporarily suppressed this warning by Wrapping my child component in React.forwardRef like:
` const ChildComponent = React.forwardRef( (props:any, ref:any)=>{ const width = props.windowWidth; return
Child Component height {width}
}
);
export default windowSize(ChildComponent); `