Closed RobertSasak closed 2 years ago
Provider should accept ReactNode instead of JSX.Element. This will allow to create nice general purpose component.
Type 'ReactNode' is not assignable to type 'Element'. Type 'undefined' is not assignable to type 'Element'.ts(2322)
import React from 'react'; import { createSignalRContext } from 'react-signalr'; import { useAuth } from './Auth'; const url = 'https://api.test.dev/hub'; const SignalRContext = createSignalRContext(); const SignalR: React.FC = ({ children }) => { const { token } = useAuth(); return ( <SignalRContext.Provider connectEnabled={!!token} accessTokenFactory={() => token} dependencies={[token]} url={url}> {children} // Workaround {children as JSX.Element} </SignalRContext.Provider> ); }; export default SignalR;
I will do it soon, thank you.
Fixed in v0.2.13
Provider should accept ReactNode instead of JSX.Element. This will allow to create nice general purpose component.
Typescript error
Usage