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

8:07 AM
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?
 
8:20 AM
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
 
9:20 AM
@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 AM
@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 AM
Is there any way to read cookie expire age?
 
 
2 hours later…
1:12 PM
@YogeshD. I’m pretty sure there isn’t
 
1:41 PM
@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…
3:03 PM
@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 (348 days later) »