reactjs

React Markdown dynamically required MD file, image relative path not working

 ̄綄美尐妖づ 提交于 2021-02-11 13:35:20
问题 i cannot get my image in the markdown file to render. I am requiring the markdown file in a react component, but the image in the md file is not rendering. absolute paths to online images are working, but relative paths are not. useEffect(() => { fetch(require(`../../../static/markdowns/${category.file}`)).then(r => r.text()).then(text => { setMarkDown(text) }) }, []) <ReactMarkdown escapeHtml={false} source={markDown}/> <img src='https://picsum.photos/200/300'></img> <img src=".

React Markdown dynamically required MD file, image relative path not working

℡╲_俬逩灬. 提交于 2021-02-11 13:33:20
问题 i cannot get my image in the markdown file to render. I am requiring the markdown file in a react component, but the image in the md file is not rendering. absolute paths to online images are working, but relative paths are not. useEffect(() => { fetch(require(`../../../static/markdowns/${category.file}`)).then(r => r.text()).then(text => { setMarkDown(text) }) }, []) <ReactMarkdown escapeHtml={false} source={markDown}/> <img src='https://picsum.photos/200/300'></img> <img src=".

Spotify API error 400: “only valid bearer authentication supported”

旧时模样 提交于 2021-02-11 13:33:06
问题 I was using the api to try and get the data of my profile through the access token. I used the given code from the authorization example code given in the website, and I used let parsed = queryString.parse(window.location.search); let accessToken = parsed.access_token; console.log(parsed); console.log(accessToken); fetch('https://api.spotify.com/v1/me', { headers: {'Authorization': 'Bearer' + accessToken}, json: true }).then((res) => res.json()) .then(data => console.log(data)); } But the 400

Display edited/styled text - react

為{幸葍}努か 提交于 2021-02-11 13:32:08
问题 I am building a web app for posting announcements. The user get to use a rich text editor, meaning he can make letters bold, underline them and so one. I am then saving this text with the description "content" in my mongodb database as a string. Every post has a title and a content. When i am displaying the post instead of showing " this text is strong " it is showing "< strong>this text is strong< /strong>". (added a space in < strong> cause it would make it strong otherwise. you get what i

Botframework Create Directline get token from server

时间秒杀一切 提交于 2021-02-11 13:28:53
问题 I saved the token from createdirectline first time it was initialized to the server. But whenever I get the token from the server and used it, it will not use that token instead it will create a new one. React.useEffect(() => { const temp = async () => { if (Object.entries(directline).length === 0) { if(await props.chatBotData!.tokenFromDb){ setDirectline(createDirectLine({ token: props.chatBotData.tokenFromDb.toString() })); }else { setDirectline(createDirectLine({ token: DIRECTLINE_SECRET }

React - Can't find the leak, infinite state declaration suspected

ε祈祈猫儿з 提交于 2021-02-11 13:27:20
问题 I'm a complete beginner in React and I was pretty happy with my first app since I, maybe, have a memory leak ? My app is very laggy after entering value in the input, after click on the add button, at bottom right, and I suspect that I don't use 'useState' like I should ? I dunno, I've been searching for hours :( ... Here's the app : https://n3g.gitlab.io/react-conso-energie/ Here's the code : In the App.js (parent) : import React, { useState } from 'react' import firebase from './firebase'

React - Can't find the leak, infinite state declaration suspected

我的梦境 提交于 2021-02-11 13:25:46
问题 I'm a complete beginner in React and I was pretty happy with my first app since I, maybe, have a memory leak ? My app is very laggy after entering value in the input, after click on the add button, at bottom right, and I suspect that I don't use 'useState' like I should ? I dunno, I've been searching for hours :( ... Here's the app : https://n3g.gitlab.io/react-conso-energie/ Here's the code : In the App.js (parent) : import React, { useState } from 'react' import firebase from './firebase'

How can I add paging on the antd select ? Because getting data from the interface is huge. So I want to implement paging

南笙酒味 提交于 2021-02-11 13:23:31
问题 How can I add paging on the Select of Antd ? Because getting data from the interface is huge. So I want to implement paging. But the document api don't support it. import { Select} from 'antd'; const Option = Select.Option; let provinceData = []; render: <Select> {provinceData.map(province => <Option>{province}</Option>)} </Select> provinceData that getting from the interface can be huge,so I expect to implement paging on antd select. When I slide to the Select bottom, it reload the new data.

React Router URL Change but Not Component

痞子三分冷 提交于 2021-02-11 13:23:29
问题 React Router change the URL but the component is not rendered I have already looked for answer but none of those example is worked Current React Router & React Router DOM version is 5.0.0 It's still plain create-react-app I've tried to use Switch tag import React, { Component } from 'react'; import logo from './logo.svg'; import './App.css'; import { BrowserRouter as Router, Route, Link } from 'react-router-dom'; const Index = () => { return <h2>Home</h2>; }; const About = () => { return <h2

React-bootstrap-table2 doesn't show data from Firebase

扶醉桌前 提交于 2021-02-11 13:22:21
问题 I've been trying to retrieve data from Firebase Realtime Database and display it in a react-bootstrap-table2, but I've run into some issues when it comes to actually displaying the data. When I run the code no value is printed into the table, however, there is no error in console. If I set the number of displayed values in the table to 25, an error occurs: Uncaught TypeError: Cannot read property 'timestamp' of undefined. However, if I console.log timestamp I first get an empty array and then