Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
22 lines
670 B
Plaintext
22 lines
670 B
Plaintext
import getConfig from '../server/react-server/getConfig.js';
|
|
import use from '../shared/use.js';
|
|
|
|
function useHook(hookName, promise) {
|
|
try {
|
|
return use(promise);
|
|
} catch (error) {
|
|
if (error instanceof TypeError && error.message.includes("Cannot read properties of null (reading 'use')")) {
|
|
throw new Error(`\`${hookName}\` is not callable within an async component. Please refer to https://next-intl.dev/docs/environments/server-client-components#async-components`, {
|
|
cause: error
|
|
});
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
function useConfig(hookName) {
|
|
return useHook(hookName, getConfig());
|
|
}
|
|
|
|
export { useConfig as default };
|