You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently experiencing an issue with the react-linkin-login-oauth2 library. I'm attempting to use a ref to the LinkedIn component in order to programmatically invoke the handleLogin function. However, I'm finding that ref.current is returning null, resulting in an error.
// truncated for brevity...
const linkedInRef = React.createRef();
// In the render method:
<LinkedIn
ref={linkedInRef}
clientId="86pfpmycxuyu49"
onFailure={handleFailure}
onSuccess={handleSuccess}
redirectUri="http://localhost:3000/linkedin"
className="d-none"
{() => {}}
// And later, when trying to invoke handleLogin:
console.log("linkedInRef.current:", linkedInRef.current);
if (isSwitchOn) {
linkedInRef.current?.handleLogin();
}
When handleLogin is invoked, I receive an error stating linkedInRef.current: null.
The LinkedIn component is not conditionally rendered, so I would expect the ref to be properly initialized. I'm using the latest versions of both React and the react-linkedin-login-oauth2 library.
Am I missing something, or is this a potential issue with the library?
Thanks in advance for your help.
The text was updated successfully, but these errors were encountered:
Hello,
I'm currently experiencing an issue with the react-linkin-login-oauth2 library. I'm attempting to use a ref to the LinkedIn component in order to programmatically invoke the handleLogin function. However, I'm finding that ref.current is returning null, resulting in an error.
// truncated for brevity...
const linkedInRef = React.createRef();
// In the render method:
<LinkedIn
ref={linkedInRef}
clientId="86pfpmycxuyu49"
onFailure={handleFailure}
onSuccess={handleSuccess}
redirectUri="http://localhost:3000/linkedin"
className="d-none"
{() => {}}
// And later, when trying to invoke handleLogin:
console.log("linkedInRef.current:", linkedInRef.current);
if (isSwitchOn) {
linkedInRef.current?.handleLogin();
}
When handleLogin is invoked, I receive an error stating linkedInRef.current: null.
The LinkedIn component is not conditionally rendered, so I would expect the ref to be properly initialized. I'm using the latest versions of both React and the react-linkedin-login-oauth2 library.
Am I missing something, or is this a potential issue with the library?
Thanks in advance for your help.
The text was updated successfully, but these errors were encountered: