0

I'm trying to follow this example, that uses PrimeReact clickable messages from PrimeReact components lib, but inside of it has a variable messages that I don't know where it comes from, and when running this file in my machine, it don't find it.

Any help will be welcome.

tomrlh
  • 1,006
  • 1
  • 18
  • 39

1 Answers1

0

I have gone through the link and tried running locally.

I too face the same issue.

I resolved it by changing import like this

import React, { Component } from "react";
import { Link } from "react-router-dom";
import { Messages } from "primereact/messages";
import { Message } from "primereact/message";
import { InputText } from "primereact/inputtext";
import { Button } from "primereact/button";

After that, it worked.

I got help from there code on GitHub where they have imported Button

Here is working package.json just in case

{
  "name": "primereact-quickstart",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-scripts": "1.1.1"
  },
  "dependencies": {
    "classnames": "^2.2.6",
    "primeicons": "1.0.0-beta.9",
    "primereact": "2.0.0-alpha.1",
    "prop-types": "^15.6.2",
    "react": "^16.4.0",
    "react-dom": "^16.4.0",
    "react-router-dom": "^4.3.1",
    "react-transition-group": "^2.5.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

Almost forgot

Answering your question of messages variable used

Its defined in HTML part of code

<Messages ref={(el) => this.messages = el} />
MyTwoCents
  • 7,284
  • 3
  • 24
  • 52