Skip to content

SideNavigation collapse again after Router action clicked #1093

Answered by tonyschwartz
tonyschwartz asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you, sir. You pointed me in the right direction. I'm brand new to Reactjs and brand new to Cloudscape. But, I like it so far. The way I solved it is with:

	const [navigationOpen, setNavigationOpen] = useState(true);
	<AppLayout
		navigationOpen={navigationOpen}
		navigation={<Navigation navCallback={() => setNavigationOpen(false)} />}

and in the Navigation component, I have:

const Navigation = ({ navCallback }) => {
	const [activeHref, setActiveHref] = useState("/");
	const navigate = useNavigate();
	const handleSideNavigationItemClick = (e) => {
		if (!e.detail.external) {
			e.preventDefault();
			navigate(e.detail.href);
			setActiveHref(e.detail.href);
		}
		if (navCallback) {…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rubencarvalho
Comment options

@tonyschwartz
Comment options

Answer selected by tonyschwartz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants