While i am using MUI library in react native they give me a error like [ERROR Invariant Violation: View config getter callback for component style
must be a function (received undefined
). Make sure to start component names with a capital letter.] this as I am not using any style in the code`
import * as React from 'react';
import Button from '@mui/material/Button';
import Stack from '@mui/material/Stack';
import {Text} from 'react-native';
import externalStyle from './Style/externalStyle'
export default function ContainedButtons() {
return (
<Stack direction="row" spacing={2}>
<Button style={style.Text}>Contained</Button>
<Button variant="contained" disabled>
Disabled
</Button>
<Button variant="contained" href="#contained-buttons">
Link
</Button>
</Stack>
);
}
(https://phpout.com/wp-content/uploads/2023/10/E3obt.png). can anyone please solve my problem. Error show
I refer some video and try external style that is also not use they give me same error
2
Answers
The issue is with the file name. You just have to rename your
externalStyle.js
file toExternalStyle.js
and update it everywhere you have usedexternalStyle.Text
toExternalStyle.Text
.The reason this is caused is because
react-native
wants you to name classes and functions with starting with capital letters and variables with camelCase.Happy coding 🙂
This is a duplicate of View config getter callback for component `style` must be a function received `undefined` Make sure to start component names with a capital
Material UI is not compatible with React Native.