New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use Zepto inside ReactJS components? #1243
Comments
Anyone?:confused: |
i'm using webpack and babel. installed
has this result
|
I'm still having this issue... Is there a better way to import zepto? |
Hi, an easy workaround, if you are using webpack, it is to use rules : [
{
test: require.resolve('zepto'),
use: 'imports-loader?this=>window',
}
] source: https://webpack.js.org/loaders/imports-loader/#webpack-config-js |
Zepto is not optimized to work with react on the server side, it needs to access the "window" and "document", but you can use it in places you are sure will only be called on the client side: componentDidMount() {
const $ = import('zepto')
$('#root').find('#header').hasClass('show')
} You can also use on dynamic components. |
When importing, or requiring got error like "Cannot read property 'createElement'" .
The text was updated successfully, but these errors were encountered: