maps icon indicating copy to clipboard operation
maps copied to clipboard

Higher level context values are not available in nested components

Open bcvazquez opened this issue 9 months ago • 1 comments

When using the Map component with custom layers within it, the higher order contexts from the App root are not available.

A very basic example in this codesandbox: https://codesandbox.io/p/sandbox/l3fh86?file=%2Fsrc%2FApp.js%3A11%2C61

The example uses the ThemeProvider from material-ui with a custom theme, I would expect that useTheme in the custom FeatureLayer would have the custom theme, but it just has the default values.

This would be true of other Providers as well, like redux store, etc.

bcvazquez avatar Mar 21 '25 18:03 bcvazquez

I dug into this, and it looks like it may be complicated to support. Here are the upstream React issues:

  • https://github.com/facebook/react/issues/17275
  • https://github.com/facebook/react/issues/13332

The react-three-fiber renderer makes use of useContextBridge from its-fine for bridging contexts between renderers. I looked into using or porting that logic, but it is non-trivial.

So no good solution yet. But open to suggestions!

tschaub avatar Mar 24 '25 00:03 tschaub