I have a functional component that is supposed to switch between the login view, and the Register view based on a hook state. React keeps passing the error: "Expected onClick listener to be a function, instead got a value of boolean type." even though I have worked on other components before the same way. Any help would be appreciated
const UserPane = () => { const [newUser, setNewUser] = useState(false) const toggleNewUser = () => setNewUser(!newUser) return ( <> <div className="container p-5 pb-2 mb-3"> {newUser ? <Register /> : <Login /> } {newUser.toString()} <a onClick={() => setNewUser(!newUser)} style= onClick> Don't have an account? Click here to register </a> </div> </> ) } https://stackoverflow.com/questions/67052163/react-rendering-different-components-based-on-hook April 12, 2021 at 11:06AM
没有评论:
发表评论