Closed esien525 closed 1 year ago
I found a solution.
Webpack,js (comment out the path.resolve(appDirectory, 'node_modules/react-native-vector-icons')
Checkbox.js
using import Icon from 'react-native-vector-icons/dist/MaterialIcons';
instead
import React from 'react'
import Icon from 'react-native-vector-icons/dist/MaterialIcons';
import iconFont from 'react-native-vector-icons/Fonts/MaterialIcons.ttf';
import { TouchableOpacity, Text, StyleSheet, Platform } from 'react-native'
if (Platform.OS === 'web') {
// Generate required css
const iconFontStyles = `@font-face {
src: url(${iconFont});
font-family: MaterialIcons;
}`;
// Create stylesheet
const style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet) {
style.styleSheet.cssText = iconFontStyles;
} else {
style.appendChild(document.createTextNode(iconFontStyles));
}
// Inject stylesheet
document.head.appendChild(style);
}
export const CheckBox = ({ selected, onPress, style, textStyle, size = 30, color = '#211f30', text = '', ...props}) => (
<TouchableOpacity style={[styles.checkBox, style]} onPress={onPress} {...props}>
<Icon
size={size}
color={color}
name={ selected ? 'check-box' : 'check-box-outline-blank'}
/>
<Text style={textStyle}> {text}</Text>
</TouchableOpacity>
)
const styles = StyleSheet.create({
checkBox: {
flexDirection: 'row',
alignItems: 'center'
}
})
Android https://github.com/oblador/react-native-vector-icons#option-manually
Hi, I'm stuck with this issue in RNW and have no clue how to fix it. Anyone can guide me? However, it is 'working' in React-Native android with missing icon.
React-Native-Web![image](https://user-images.githubusercontent.com/16555152/180701800-fb5d1671-1917-47e8-ad23-55fc302f1537.png)
React-Native (Android)![image](https://user-images.githubusercontent.com/16555152/180703499-5d50d4b0-cac1-46a2-bf9c-db1f594e1066.png)
Checkbox.js
Login.js
Webpack.js![image](https://user-images.githubusercontent.com/16555152/180702122-54dc0f2e-3e3a-47c2-8c0d-5c71be2577b3.png)