File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -177,20 +177,25 @@ export const NotionContextProvider: React.FC<PartialNotionContext> = ({
177177} ) => {
178178 for ( const key of Object . keys ( rest ) ) if ( rest [ key ] === undefined ) delete rest [ key ]
179179
180- const wrappedThemeComponents = React . useMemo (
181- ( ) => ( {
182- ...themeComponents
183- } ) ,
184- [ themeComponents ]
185- )
180+ const wrappedThemeComponents = React . useMemo ( ( ) => {
181+ const components = { ...themeComponents }
182+
183+ if ( components . nextImage ) components . Image = wrapNextImage ( components . nextImage )
184+
185+ if ( components . nextLink ) {
186+ const nextLink = wrapNextLink ( components . nextLink )
187+ components . nextLink = nextLink
186188
187- if ( wrappedThemeComponents . nextImage ) wrappedThemeComponents . Image = wrapNextImage ( themeComponents . nextImage )
189+ if ( ! components . PageLink ) components . PageLink = nextLink
190+ if ( ! components . Link ) components . Link = nextLink
191+ }
188192
189- if ( wrappedThemeComponents . nextLink ) wrappedThemeComponents . nextLink = wrapNextLink ( themeComponents . nextLink )
193+ // ensure the user can't override default components with falsy values
194+ // since it would result in very difficult-to-debug react errors
195+ for ( const key of Object . keys ( components ) ) if ( ! components [ key ] ) delete components [ key ]
190196
191- // ensure the user can't override default components with falsy values
192- // since it would result in very difficult-to-debug react errors
193- for ( const key of Object . keys ( wrappedThemeComponents ) ) if ( ! wrappedThemeComponents [ key ] ) delete wrappedThemeComponents [ key ]
197+ return components
198+ } , [ themeComponents ] )
194199
195200 const value = React . useMemo (
196201 ( ) => ( {
You can’t perform that action at this time.
0 commit comments