Comments (9)
const styles = StyleSheet.create({
wrapper: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}
});
from react-native-htmlview.
Is there any progress on this? textAlign: 'center' still doesn't work for me.
from react-native-htmlview.
@reni99, @dan-katz
I just used the following:
The HTML view usage using the renderNode prop function for custom rendering
<HTMLView value={this.props.item.description()} stylesheet={descriptionStyles}
renderNode={this.renderDescription}/>
Render my node function
renderDescription = (node, index, list, parent) => {
if (node.type === 'text') {
return (
<Text key={index} style={descriptionStyles.p}>
{entities.decodeHTML(node.data)}
</Text>);
} else if (node.type === 'tag') {
return (
<View>
{node.children.map(this.renderDescription)}
</View>)
}
return false;
}
Style
const descriptionStyles = StyleSheet.create({
p: {
color: 'white',
fontSize: 18,
textAlign: 'center',
},
});
from react-native-htmlview.
I tried the above code, but it doesn't work. Has anyone found the solution?
from react-native-htmlview.
Here is what I did.
Define the element like this
const htmlContent = `<a href="http://path-to-your-link.com">link</a>`;
And use it like this
<View style={{ flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }}>
<HTMLView
value={htmlContent}
/>
</View>
from react-native-htmlview.
The HTMLView
accepts an (undocumented) style
prop. So you could also apply the wrapper style directly to the HTMLView
:
<HTMLView
style={{ alignItems: 'center', justifyContent: 'center' }}
value={ htmlString } />
from react-native-htmlview.
i got the solution
i use the 0.9.0. change the line 96 in htmlToElement.js to like this
<View key={index} onPress={linkPressHandler}> {linebreakBefore} {listItemPrefix} {domToElement(node.children, node)} {linebreakAfter} </View>
from react-native-htmlview.
@xsgkaka This throws an error of RawText "" must be wrapped in an explicit <Text> component
and @flavordaaave solution only center aligns the first tag if you have multiple tags. I found a global solution, I created a PR for it #116 this makes the entire value of the component align text center. due to the implementation it is complicated to make them independently align text. But if you are looking to align the entire value then this works good.
UPDATE: I updated the PR with the actual fix, it now individually aligns each tag according to what you want, I have a nice explanation on the PR #116 about what was causing it and the fix of course.
from react-native-htmlview.
Should work as soon as 0.12 is published 😄
from react-native-htmlview.
Related Issues (20)
- Unordered List followed by Paragraph not rendering properly HOT 3
- Space between html tags is huge even tho I wrapped my content in "<div>" HOT 4
- Inline styling is not working HOT 1
- Get text of clicked links
- How to set the number of lines to show HOT 1
- Truncate text in html view HOT 1
- Get raw html in renderNode HOT 2
- Make HTML Text selectable HOT 4
- Multiple HyperLinks
- img tag have default border HOT 1
- Update HTMLView TS definitions to support class components
- <sup> and <sub> tag not working HOT 3
- Typing for HTMLViewNode on Typescript HOT 2
- dynamically set height according to available content
- import ViewPropTypes from deprecated-react-native-prop-types instead of react-native HOT 5
- Is there a way to ignore links ? HOT 1
- Error: Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'. HOT 3
- can add katex css to this html view ? HOT 1
- Please Help me to Solve this Error << ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'. HOT 2
- ViewPropTypes will be removed from 'react-native' HOT 2
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 react-native-htmlview.