skip to Main Content

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


  1. The issue is with the file name. You just have to rename your externalStyle.js file to ExternalStyle.js and update it everywhere you have used externalStyle.Text to ExternalStyle.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 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search