ReactJS Failed Prop Type With 'undefined' Value

Darren Sweeney

I've looked at other similar questions but can't seem to find an answer...

I'm getting error:

Warning: Failed prop type: The prop height is marked as required in AudioPlayer, but its value is undefined.

When trying the following code:

import React, { Component } from "react";
import { Row, Col } from "react-bootstrap";
import Audio from "react-audioplayer";
import "./../../Assets/Css/AudioPlayer.css";
import PropTypes from "prop-types";

export default class AudioPlayer extends Component {
    render(props) {
        const playlist = this.props.playlist;

        const AudioStyles = {
            width: "99%",
            margin: "1% 0"
        };

        const AudioProps = {
            height: 600,
            style: AudioStyles,
            playlist: playlist,
            fullPlayer: true
        };

        return (
            <Row>
                <Col xs={12}>
                    <Audio {...AudioProps} />
                </Col>
            </Row>
        );
    }
}

AudioPlayer.propTypes = {
    height: PropTypes.number.isRequired
};

The code still functions as expected but gives the error mentioned above.

Should I be checking prop types differently?

Shubham Khatri

From what I see in your question description, uou have no dependency of prop height in the AudioPlayer component. You would rather want it in the Audio Component and hence you need to specify Proptype for the Audio component

so In the Audio component file add and remove from AudioPlayer component file.

Audio.propTypes = {
    height: PropTypes.number.isRequired
};

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Failed prop type The prop is marked as required but its value is `undefined`

reactjs Delete Operation Warning: Failed prop type: The prop `role` is marked as required in `ManageRolePage`, but its value is `null`

How to fix this issue “Warning: Failed prop type: The prop `title` is marked as required in `Tab`, but its value is `undefined`.”

Warning: Failed prop type: The prop `store` is marked as required in `Provider`, but its value is `undefined`. in Provider

Failed prop type: The prop `children` is marked as required in `InputAdornment`, but its value is `undefined`

Failed prop type: The prop `options` is marked as required in `signupCheckBoxes`, but its value is `undefined`

Failed prop type: The prop `children` is marked as required in` Sidebar`, but its value is `undefined`

Warning: Failed prop type: The prop `createCourse` is marked as required in `CoursesPage`, but its value is `undefined`

Warning: Failed prop type: The prop open is marked as required in Snackbar, but its value is undefined

Failed prop type: The prop todos[0].id is marked as required in TodoList, but its value is undefined

Failed prop type: The prop `userSignUpRequest` is marked as required in `Login`, but its value is `undefined`

Failed prop type: The prop `children` is marked as required in `Mutation`, but its value is `undefined`

Warning: Failed prop type: The prop `todos[0].title` is marked as required in `TodoList`, but its value is `undefined`

Failed prop type: The prop `auth` is marked as required in `Navbar`, but its value is `undefined`

Warning: Failed prop type: The prop `alt` is marked as required in `MainImage`, but its value is `undefined`. MainImage

React - Failed prop type: The prop `history` is marked as required in `Router`, but its value is `undefined`

Failed prop type: Invalid prop 'value'

Failed prop type: Invalid prop `value` of type `number`

Failed prop type: MUI: The getting warning in reactjs + mui?

React : Warning: Failed prop type: Cannot read property 'apply' of undefined

Failed prop type. Required prop types are undefined in my redux store

Failed prop type: The prop `href` expects a `string` or `object` in `<Link>`, but got `undefined` instead

Nextjs13 Error: Failed prop type: The prop `href` expects a `string` or `object` in `<Link>`, but got `undefined` instead

React Failed prop type: value without onChange handler

Failed prop type: Invalid prop 'value' of type 'object' supplied to 'TextInput' React Native

Warning: Failed prop type: Invalid prop `value` of type `number` supplied to `TextInput`, expected `string`

Location prop undefined on refresh (ReactJS)

[Vue warn]: Invalid prop: type check failed for prop "page". Expected Number with value 0, got String with value ""

Invalid prop: type check failed for prop "value". Expected Boolean, got String with value "0"

TOP Ranking

HotTag

Archive