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 do I use cheerio
in react native
?
#1058
Comments
Same issue |
Can you try to: npm install events I know this seems counter intuitive, in Node.js this is available by default, maybe not in react native? |
Not work for me, next error appear: |
Seems like a recurrent issue in the react-native repository, ask the question here and provide a reproduction repository. This is not specific to cheerio. |
I found the problem.
|
after installing 'react-native-fence-html' problem disappear, it seems to me it includes all required dependencies ) |
@niocncn One of the libraries helped me, look https://github.com/oyyd/cheerio-without-node-native No errors, can correctly parse. import React, { Component } from 'react';
import { StyleSheet, View, Text } from 'react-native';
import cio from 'cheerio-without-node-native';
export default class App extends Component {
constructor(props) {
super(props);
this.$ = cio.load('<p class="hello" style="color: red">Hello world</p>');
}
render() {
return (
<View style={styles.container}>
<Text style={styles.text}>{this.$('.hello').text()}</Text>
<Text style={styles.text}>{this.$('.hello').attr('style')}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
text: {
fontSize: 30
}
}); |
You can install the missing packages from npm ( I would not recommend the usage of a fork as it will make it difficult to track down issues and will delay, if not prevent, patches for bugs. |
What about |
@fb55 The hack of requiring |
Thanks very much for this topic. I had the same issue it was great to see solution right away on search. |
* Reduced cmn by moving to lodash, and stripTags to top level utils dir (pick as functions dependency not yet removed) * Removing my extract html functions and moving to cheerio * cheerio depends on htmlparser2 which depends on native node environment, so I had to resort to the 3rd party non node native * cheeriojs/cheerio#1058
@Lizhooh 世界上最远的距离就是我不知道轮子的存在 |
try: |
You can install
If you are using NPM instead of Yarn, I think newer versions of NPM also support this. |
I like the
cheerio
library. I want to usecheerio
inreact native
, but it didn't workThe text was updated successfully, but these errors were encountered: