reactjs

Heroku only displaying backend of MERN app. How can I fix this?

送分小仙女□ 提交于 2021-02-10 06:27:19
问题 I've finished working on my first MERN app. It works locally and it was 'successfully built' on Heroku but all that is displayed is the backend-data retrieved for the '/' route from MongoDB. I've looked at a couple of resources that discuss deploying MERN stack apps to Heroku here: 1. https://www.freecodecamp.org/forum/t/solved-deployment-problem-showing-backend/280178 2. https://www.freecodecamp.org/news/how-to-deploy-a-react-app-with-an-express-server-on-heroku-32244fe5a250/ I've tried

React scripts fails while i run concurrently with nodemon

爷,独闯天下 提交于 2021-02-10 06:24:10
问题 When i run npm start the above error occurs. my script in package.json: "start": "concurrently \"nodemon server\" \"react-scripts start\"", Any help will be great ! 回答1: One of the ways you can do is (You can amend it accordingly) : "server": "nodemon index.js", "react": "react-scripts start" "dev": "concurrently \"npm run server \" \"npm run react\" " And then do npm run dev You can read more about concurrently here 来源: https://stackoverflow.com/questions/49818438/react-scripts-fails-while-i

Line 5: 'props' is not defined no-undef

馋奶兔 提交于 2021-02-10 06:24:08
问题 I'm trying to create a randomiser for the data I get from the API; however I get this "Line 5: 'props' is not defined no-undef" error and don't see what's wrong with it. import React from "react"; class Random extends React.Component { constructor() { super(props); this.state = { breweries: [] }; } componentDidMount() { fetch("https://api.openbrewerydb.org/breweries") .then(response => response.json()) .then((data) => { this.setState({ breweries: data, }) }) } render() { const brewery = this

Why React needs webpack-dev-server to run?

夙愿已清 提交于 2021-02-10 06:19:12
问题 I'm new to React and I followed Facebook's Installation (Create a New App). So every time I need to run the app, it needs to start a server. When I try to open the build version in chrome( opening HTML directly ), nothing gets displayed. Then I tried to setup React environment myself from scratch using codecademy tutorial. Here, after I build the project, I can directly open the HTML in chrome and the contents are displayed. My question is: Why webpage doesn't get displayed in the 1st method

Cannot read property `.then` of undefined with axios and react in actions

心不动则不痛 提交于 2021-02-10 06:18:19
问题 I am using axios in an action and trying to call that action with a chaining action. I will show what I am trying to do here: this.props.fetchOffers().then(() => { this.props.filter(this.props.filterOption); }); But I get an error: Cannot read property 'then' of undefined . What I do not get is that right below this function I have another action that is doing this exact same thing and working just fine. this.props.sortOffers(value).then(() => { this.props.filter(this.props.filterOption); });

Why React needs webpack-dev-server to run?

扶醉桌前 提交于 2021-02-10 06:18:12
问题 I'm new to React and I followed Facebook's Installation (Create a New App). So every time I need to run the app, it needs to start a server. When I try to open the build version in chrome( opening HTML directly ), nothing gets displayed. Then I tried to setup React environment myself from scratch using codecademy tutorial. Here, after I build the project, I can directly open the HTML in chrome and the contents are displayed. My question is: Why webpage doesn't get displayed in the 1st method

Cannot read property `.then` of undefined with axios and react in actions

非 Y 不嫁゛ 提交于 2021-02-10 06:17:33
问题 I am using axios in an action and trying to call that action with a chaining action. I will show what I am trying to do here: this.props.fetchOffers().then(() => { this.props.filter(this.props.filterOption); }); But I get an error: Cannot read property 'then' of undefined . What I do not get is that right below this function I have another action that is doing this exact same thing and working just fine. this.props.sortOffers(value).then(() => { this.props.filter(this.props.filterOption); });

BotFramework-Webchat Middleware for renderMarkdown

扶醉桌前 提交于 2021-02-10 06:15:37
问题 I'd like to add renderMarkdown using the React component in the Bot framework. I am able to add through HTML like below and it's working as expected but my requirement is to add the same feature using the react. <!DOCTYPE html> <html> <head> <script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script> <script src="https://www.acai-hub.com/js/markdown-it.min-8.4.2.js"></script> <style> html, body { height: 100%; } body { margin: 0; } #webchat { height: 100%;

React AsyncTypeahead using Typescript

我们两清 提交于 2021-02-10 06:15:19
问题 I'm trying to use the module React Bootstrap Typeahead (original and type versions) in React using tsx files. Im using the following versions: "@types/react-bootstrap-typeahead": "3.4.5" "react-bootstrap-typeahead": "3.4.3" I builded the following SimpleAsyncExample class, trying to test the component by always return the same results no matter what the user types, but with a delay in the response... import * as React from 'react'; import {AsyncTypeahead, ClearButton, Token} from 'react

How to Post data to database using Fetch API in React.js

懵懂的女人 提交于 2021-02-10 06:10:32
问题 I have recently learned how to set up a simple api in my express server using a localhost mySQL database I have running on a MAMP server. After I set that up I learned how to have React.js fetch that data and display it. Now I want to do the reverse and post data from a form I created in React.js. I would like to continue using the fetch API to post that data. You can view my code below. Below is my express server code for my api. app.get('/api/listitems', (req, res) => { connection.connect()