score:1
Accepted answer
add some parenthesis around those two expressions with the ||
between them if they should be evaluated together.
((user.userid && user.otpverified) || (user.userid && user.loginwithpassword))
this change makes your login
component show based on the values.
you can remove the inner ones too and the &&
will be evaluated first.
(user.userid && user.otpverified || user.userid && user.loginwithpassword)
else if (
(user.userid && user.otpverified || user.userid && user.loginwithpassword)
&& !user.profilecompleted
&& match.path === '/complete-profile'
)
console.log((true && true) || (true && false) && false && false) //true
console.log((true && true || true && false) && false && false) // false
Source: stackoverflow.com
Related Query
- ReactJS complex (if / else if) not working as expected
- Using useState of complex object not working as expected in ReactJS
- copy to clipboard is not working as expected in reactjs
- Re-rendering state in Reactjs not working as expected
- reactJS map function not working as expected
- ReactJS Bootstrap Navbar and Routing not working together
- Jest expect.any() not working as expected
- ReactJS Router V4 history.push not working
- Formik & yup form validation not working as expected with VirtualizedSelect
- Inline style is not working ReactJS
- In React, onMouseEnter or hover is not working as expected
- clearInterval is not working in reactjs
- Reactjs - Demo Application is not working
- PrivateRoute not working in reactjs react-router-dom
- reactjs chrome extension message passing not working
- fireEvent.keyDown not working as expected on my Jest + React Testing Library test
- ReactJS - SCRIPT1010: Expected identifier - Production build not running on IE11
- export default not working webpack, reactjs
- ReactJS Array.push function not working in setState
- cookies.remove('abc') not working in reactJs
- Simple ReactJs Example not working
- ReactJS - FCM not working in safari browser
- ReactJS - ref not working with connect and redux-form
- Babel plugin-proposal-decorators not working as expected
- ReactJS & Google MDL Button onClick not working
- ReactJS CSS Class not working
- react-bootstrap not working as expected
- sequential setState calls not working as expected
- React onLoad img event not working as expected
- ReactJS - video stream from webcam not working
More Query from same tag
- Access-Control-Allow-Origin in React JS on Meteor App
- 'action' is not defined in Redux
- React: Rerender component if prop changed
- how to conditional render a styled component in react?
- React MUI Chip onDelete access to stopPropagation method
- what is proper way to import multiple components from same file in react instead of getting each component imported
- reactjs make content appear next to sidebar
- React Redux: Testing mapStateToProps and mapDispatchToProps with Enzyme/Jest
- Infinite loop when set with React Hooks
- How to handle onKeyDown/Up opening the list items in React
- getting error map function is not defined
- Circle checkbox in react.js
- JSX does not compile in for loop
- Get Firebase Collection into simple array
- I need my ReactJS app working offline without server
- Redux Saga stopped by LOCATION_CHANGE too early
- Porting WordPress Gutenberg to a Standalone React Component - CSS Styles Not Appearing
- Rerendering React child component when the parent updates its props in a Next.js app
- enzyme test contains for container
- Is there a way to pass in a variable dynamically into a toggle function without causing a looping error
- React.JS Cannot read property within an Array loop
- react-hook-form custom validation message not showing
- React this.props is undefined in state event?
- Invariant Violation: findComponentRoot when using Link & Tables
- Add a maximum number of days with react-dates
- React - Conditional rendering is not working well
- How to get multiple input fields's values in use state hook
- How to find data in JSON with unique keys?
- Limit selection of checkboxes react
- React hooks synchronise two arrays