'Cannot read properties of undefined (reading 'create') in a .js file
I have this problem with a .js. I have tried to change some ";" with "," and to see where the problem is by the lane but i can`t see the problem.
The code is:
import React from 'react';
import { TouchableOpacity, Text, Stylesheet } from 'react-native';
export const RoundedButton = ({
style = {},
textStyle = {},
size = 125,
...props
}) => {
return (
<TouchableOpacity style={[styles(size).radius, style]}>
<Text style={[styles(size).text, textStyle]}>{props.title}</Text>
</TouchableOpacity>
);
};
const styles = (size) =>
Stylesheet.create({
radius: {
borderRadius: size / 2,
width: size,
height: size,
alignItems: 'center',
},
text: { color: '#fff', fontSize: 20 },
});
and the problem is:
TypeError: Cannot read properties of undefined (reading 'create')
at styles (src/components/RoundedButton.js.js:19:14
at RoundedButton (src/components/RoundedButton.js.js:12:31
Solution 1:[1]
You have a typo in StyleSheet. It is named StyleSheetnot Stylesheet.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | David Scholz |
