Dashboard.js

import React from 'react';

const Dashboard = () => {
    return (
        <!--  Card Section  -->
        <div className="row">
            <div className="col s12 m6 l3">
                <div className="card blue-grey darken-1">
                    <div className="card-content white-text">
                        <span className="card-title center">20</span>
                        <p className="center">Task of Today</p>
                    </div>
                </div>
            </div>

            <div className="col s12 m6 l3">
                <div className="card blue-grey darken-1">
                    <div className="card-content white-text">
                        <span className="card-title center">20</span>
                        <p className="center">Bugs</p>
                    </div>
                </div>
            </div>

            <div className="col s12 m6 l3">
                <div className="card blue-grey darken-1">
                    <div className="card-content white-text">
                        <span className="card-title center">20</span>
                        <p className="center">Finished Task</p>
                    </div>
                </div>
            </div>

            <div className="col s12 m6 l3">
                <div className="card blue-grey darken-1">
                    <div className="card-content white-text">
                        <span className="card-title center">20</span>
                        <p className="center">Remaining Task</p>
                    </div>
                </div>
            </div>
        </div>
    )
}

export default Dashboard;

Après avoir importé cela depuis app.js, obtenant cette erreur

./src/components/Dashboard/Dashboard.js
TypeError: Cannot read property 'code' of undefined
    at parser.next (<anonymous>)
    at normalizeFile.next (<anonymous>)
    at run.next (<anonymous>)
    at transform.next (<anonymous>)

Je n'ai aucune idée de ce qui se passe. Il n'y a pas de code variable. D'où ça vient ? L'application fonctionne bien si je n'importe pas le tableau de bord. Erreur lors de l'importation de Dashboard.js dans app.js.

0
Ghost420 16 sept. 2020 à 12:02

1 réponse

Meilleure réponse

Essayez de supprimer le commentaire <!-- Card Section --> dans le composant et cela devrait fonctionner.

Correction:

import React from 'react';

const Dashboard = () => {
    return (
        <div className="row">
            <div className="col s12 m6 l3">
                <div className="card blue-grey darken-1">
                    <div className="card-content white-text">
                        <span className="card-title center">20</span>
                        <p className="center">Task of Today</p>
                    </div>
                </div>
            </div>

            <div className="col s12 m6 l3">
                <div className="card blue-grey darken-1">
                    <div className="card-content white-text">
                        <span className="card-title center">20</span>
                        <p className="center">Bugs</p>
                    </div>
                </div>
            </div>

            <div className="col s12 m6 l3">
                <div className="card blue-grey darken-1">
                    <div className="card-content white-text">
                        <span className="card-title center">20</span>
                        <p className="center">Finished Task</p>
                    </div>
                </div>
            </div>

            <div className="col s12 m6 l3">
                <div className="card blue-grey darken-1">
                    <div className="card-content white-text">
                        <span className="card-title center">20</span>
                        <p className="center">Remaining Task</p>
                    </div>
                </div>
            </div>
        </div>
    )
}

export default Dashboard;
3
Bahroze Ali 16 sept. 2020 à 09:39