-
-
Notifications
You must be signed in to change notification settings - Fork 384
Open
Labels
Description
Description
pages/admin-panel/+Layout.js
# Data used by +Layout.js
pages/admin-panel/+data.once.js# Setting pageContext.user
pages/+onCreatePageContext.once.jsIf a hook uses the .once.js suffix then:
- Upon client-side navigation, the hook isn't called again if it's shared (between the previous and next page)
- Only make a
pageContext.jsonrequest if a server-side hook should be called
- Only make a
- All
pageContextvalues set a.once.jshook are cached on the client-side- Thus, for server-side hooks, only
passToClientproperties are cached (on the client-side) - Deprecate the
passToClientsettingonce: truein favor of.once.js - Requires: Flat
pageContext#1268 - Clear the entire cache upon page reload (i.e. the next URL equals the previous URL)? So that user can click on the active link to reload the page (or when the app calls
reload()).
- Thus, for server-side hooks, only
Optionally: #2565
- I think we can release it as a
MINOR BREAKING CHANGE?- It can break apps, but only unlikely so
- It may make superfluous
pageContext.jsonrequests (the user will have to use.once.jsto avoid these)
- Migration guide for
renderPage()withpassToClient: [{ prop: 'user', once: true }]:- renderPage({ user }) + renderPage({ req }) + + // pages/+onCreatePageContext.once.js + export default (pageContext) => { + pageContext.user = getUser(pageContext.req) + }
PheysX, YKDZ, Inviz, rtritto and tperale