Comments (13)
@sdtsui Many thanks for this.
import ShadowDOM from 'react-shadow';
doesn't work because:
ShadowDOM
is using React 15.x and ReactDOM 15.x;App
is using React 0.14.x and ReactDOM 0.14.x;
import ShadowDOM from './react-shadow-compiled.js';
does work because:
ShadowDOM
is using 0.14.x and ReactDOM 0.14.x;App
is using React 0.14.x and ReactDOM 0.14.x;
(Same applies for import ShadowDOM from './react-shadow.js'
)
The versions of ShadowDOM
change because both React
and ReactDOM
are defined as externals in Webpack, and so when using the former version it uses the node_modules
in the ReactShadow
directory (because your package.json
don't meet the version requirements), whereas in the latter you're using a local copy and so it takes the versions directly from the create-react-app
's package.json
.
I updated ReactShadow
about 2 months ago for React 15.x and didn't actually realise that it also works for the 0.14.x
combination. If it does work, as appears to be the case, then I think we can relax the React and ReactDOM versions even further to support both 14 and 15. However a mixture of both, as we've found out, seems to cause problems, and I suppose rightfully so.
To fix ReactShadow
in the create-react-app
repo you need to update React and ReactDOM to 15.x
.
Nevertheless, I don't think this relates to @nruhe's original issue – that to me sounds like a separate issue relating to adding Redux into the mix. I'll relax the ReactShadow
dependency versions and see what transpires.
Thanks for taking the effort to investigate @sdtsui 🍻
from reactshadow.
@nruhe would be great to get a fiddle for this — could then see what we can do to make things work 👍
from reactshadow.
Sure, I'll make some time this weekend. :)
from reactshadow.
Update: I swear, this is on my TODO list, I've just been to busy. I'll send you a fiddle as soon as I can.
from reactshadow.
Any updates on this @nruhe ? I might be able to help: running into the same issue.
from reactshadow.
Folks, for this issue it would be great if one of you could setup a simple JSFiddle please. I can then understand your setup and begin to help 👍
from reactshadow.
@Wildhoney Thanks for replying! What's the best way to setup the fiddle? I don't use fiddles much and I'm not sure how to load react-shadow
into the environment, used to using libraries like this with a build process.
I'm also getting the following error, independent of using redux (trying to render at the top of my tree):
react-shadow.js:1369Uncaught TypeError: Cannot read property 'attachShadow' of null(…)
stack trace:
printWarning @ warning.js:36warning @ warning.js:60checkType @ ReactPropTypes.js:134checkPropTypes @ ReactElementValidator.js:178validatePropTypes @ ReactElementValidator.js:208createElement @ ReactElementValidator.js:242Root @ Root.dev.js:16mountComponent @ ReactCompositeComponent.js:148mountComponent @ ReactReconciler.js:37mountComponent @ ReactCompositeComponent.js:225mountComponent @ ReactReconciler.js:37mountComponentIntoNode @ ReactMount.js:266perform @ Transaction.js:136batchedMountComponentIntoNode @ ReactMount.js:282perform @ Transaction.js:136batchedUpdates @ ReactDefaultBatchingStrategy.js:62batchedUpdates @ ReactUpdates.js:94_renderNewRootComponent @ ReactMount.js:476_renderSubtreeIntoContainer @ ReactMount.js:550(anonymous function) @ index.js:11__webpack_require__ @ bootstrap 010f9f7…:553fn @ bootstrap 010f9f7…:84(anonymous function) @ bootstrap 010f9f7…:576__webpack_require__ @ bootstrap 010f9f7…:553(anonymous function) @ bootstrap 010f9f7…:576(anonymous function) @ bootstrap 010f9f7…:576
react-shadow.js:1369Uncaught TypeError: Cannot read property 'attachShadow' of null(…)
I'd love to prepare fiddles (or another format, even a repo) for both if you like. Let me know what you think of the above.
Thanks again,
from reactshadow.
Still trying to get to the bottom of this. I found that the library didn't work for react 14.7, worked for react 15, and didn't work when paired with a tree that used react-redux. This was done by creating a simple create-react-app
directory, and rendering a span in the ShadowDOM
component. All of these problems were resolved when importing the source file directly (without npm, just a local copy of react-shadow.js
.
@Wildhoney Are there any old issues related to the build process or minified version? Let me know if you have any thoughts.
from reactshadow.
Hmm, even more curious. There's nothing special happening – it's just the normal Babel transpilation. I re-coded this library for React 15.
Does it break when you use the compiled version?
from reactshadow.
Yep, it does.
I've made a repo with the three different imports: npm module, compiled, and source. Feel free to clone down and try yourself. Let me know if you have any questions, or would like this simplified more.
https://github.com/sdtsui/create-react-app/blob/rs/src/App.js
Thanks!
from reactshadow.
I'm facing the same issue and I'm only using React-Redux not Redux-Fractal.
It does not work in the following ways:
- 1st attempt
<ShadowDOM include={['css/common.css']}>
<Provider store={this.props.store}>
<div>
// [...] stuff here
</div>
</Provider>
</ShadowDOM>
- 2nd attempt
<Provider store={this.props.store}>
<ShadowDOM include={['css/common.css']}>
<div>
// [...] stuff here
</div>
</ShadowDOM>
</Provider>
Errors:
I tried to do a fiddle reproducing those errors but I don't know how to use ReactShadow in JSFiddle
from reactshadow.
@herodrigues thanks – the second attempt is how I'd imagine ShadowDOM
to work. I'll investigate the issue when using in conjunction with Redux 👍
from reactshadow.
Fixed in 86b9ed1
from reactshadow.
Related Issues (20)
- Can useLayoutEffect() be used instead of useEffect() to make rendering synchronous? HOT 3
- How to use ReactShadow with ChakraUI Drawers? HOT 1
- Is there any chance to have a working example with CRA and TS? HOT 1
- Lib stopped working on iOS 15? HOT 1
- Shadow tree inheriting from parent HOT 2
- Does it support new mui lib?
- [feature request] allow consumers to pass options to emotion
- global requires a polyfill. Shall we replace global with globalThis? HOT 2
- styled-components is not defined as a peer dependency HOT 1
- Update dependency to React 18? HOT 5
- Trouble Loading Custom Font Into Shadow DOM in my Chrome Extension
- template content is empty with react HOT 1
- Example links in readme are both broken
- Children of the shadow root cannot get retrieved at parent level within a useEffect
- Failed to execute 'attachShadow' on 'Element': Shadow root cannot be created on a host which already hosts a shadow tree HOT 1
- Remove react-use dependency due to package size
- shadowroot has been depricated need to update with shadowrootmode in template element HOT 2
- Next.js v13 failed to build "TypeError: e.createContext is not a function" HOT 1
- Css Variables from External URL link inside of a shadow dom not getting recognized
- Warning: z: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactshadow.