Skip to content

Commit

Permalink
Add warning when namespacesRequired is not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
isaachinman committed Dec 17, 2018
1 parent c866373 commit 7f7fc63
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"react/jsx-filename-extension": 0,
"react/prefer-stateless-function": 0,
"no-restricted-syntax": 0,
"no-eval": 0
"no-eval": 0,
"no-console": ["error", {
"allow": ["warn", "error"]
}]
}
}
4 changes: 3 additions & 1 deletion src/hocs/app-with-translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ export default function (WrappedComponent) {
}

// Step 2: Determine namespace dependencies
let namespacesRequired = config.allLanguages
let namespacesRequired = config.ns
if (Array.isArray(pageProps.namespacesRequired)) {
({ namespacesRequired } = pageProps)
} else if (process.env.NODE_ENV !== 'production') {
console.warn(`You have not declared a namespacesRequired array on your page-level component: ${Component.displayName}. This will cause all namespaces to be sent down to the client, possibly negatively impacting the performance of your app. For more info, see: https://github.com/isaachinman/next-i18next#4-declaring-namespace-dependencies`)
}

// Step 3: Perform data fetching, depending on environment
Expand Down

0 comments on commit 7f7fc63

Please sign in to comment.