<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zainal Shariff</title>
    <description>The latest articles on DEV Community by Zainal Shariff (@zinujust).</description>
    <link>https://dev.to/zinujust</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F966380%2F0ef7d265-1723-4817-8203-9fd36ffab53b.png</url>
      <title>DEV Community: Zainal Shariff</title>
      <link>https://dev.to/zinujust</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zinujust"/>
    <language>en</language>
    <item>
      <title>useNavigate not working in Ternary operator</title>
      <dc:creator>Zainal Shariff</dc:creator>
      <pubDate>Sat, 05 Nov 2022 21:50:36 +0000</pubDate>
      <link>https://dev.to/zinujust/usenavigate-not-working-in-ternary-operator-8ii</link>
      <guid>https://dev.to/zinujust/usenavigate-not-working-in-ternary-operator-8ii</guid>
      <description>&lt;p&gt;Hi guys, I'm a newbie in ReactJS and I am working on a Banking Application to get better at this library. At the moment I am stuck with a React Router problem while signing-in. To simplify my question, I have removed the JWT implementation. Basically the setAuthentication should set isAutheticated to true and then based on the ternary operator, I should be sent to "/home" and if false then the index page "/". However, every time I click on submit, I am routed to the "/" path. The router has already been set in the App.js file for both the paths mentioned. Also, when I use navigate outside of the ternary operator, it works and I am sent to the "/home" path. What could be the problem?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [email, setEmail] = useState('')
const [password, setPassword] = useState('') 
const dispatch = useDispatch(); 
const { token, isAuthenticated } = useSelector((state) =&amp;gt; state.userLogin) 
const navigate = useNavigate();

const handleSubmit = (e) =&amp;gt; { e.preventDefault();
 dispatch(setAuthentication())

 isAuthenticated === true ? navigate('/home') : navigate('/');

 setEmail('');
 setPassword('')
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
