« first day (4605 days earlier)      last day (565 days later) » 

08:07
in React/TS, I want to show some tags in the header or footer on the page, based on the content of the page you are on
the page is within routes, but the header and footer are not
how would I signal the footer what tags to render based on what page I am?
08:20
basically what I want is something like this:
function App() {
	return <>
		<Header/>
		<Content/>
		<Footer/>
	</>;
}

function Content() {
	return <div>
		<CustomContext.Provider>
			...
		</CustomContext.Provider>
	</div>
}

function Footer() {
	return <div>
		<CustomContext.Consumer>
			...
		</CustomContext.Consumer>
	</div>;
}
however, as far as I understand how contexts work, this will not work as intended
09:20
@Wietlol ye, consumer and useContext hooks need to be called inside components which are "inside" the provider
function App() {
    return (
        <CustomContext.Provider>
            <Header />
            <Content />
            <Footer />
        </CustomContext.Provider>
    );
}

function Content() {
    const [ctxState, setCtxState] = useContext(CustomContext);
    const routes = useRoutes();
    useEffect(() => {
        // something with routes
        setCtxState({...})
    }, [routes, setCtxState])
    return <div>...</div>;
}

function Footer() {
    return (
        <div>
            <CustomContext.Consumer>...</CustomContext.Consumer>
so more something like that
 
1 hour later…
10:37
@vvspower Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
@VLAZ I believe we need some RO power
@makadev the problem then is that it would be difficult to kind of "reset" the footer once you go to a different page
but this looks promising github.com/camwest/react-slot-fill
basically reserving some space in the footer to be defined by other components
11:06
Is there any way to read cookie expire age?
 
2 hours later…
13:12
@YogeshD. I’m pretty sure there isn’t
13:41
@YogeshD. it depends. If it's an HTTP-only cookie, nope (not on the client at least, but possible server-side, of course). If not - see the Cookie interface, piece of cake: developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/…
 
1 hour later…
15:03
@OlegValteriswithUkraine just a more complicated explanation of my simple explanation lol
how so? HTTP-only cookies can't be read client-side period, not even in part, that's their purpose for security reasons. If one can read the cookie value at all, they can also read their expiration date.

« first day (4605 days earlier)      last day (565 days later) »