reactjs

Binding methods in react components

[亡魂溺海] 提交于 2021-02-11 04:57:20
问题 I'm getting an error when I try to bind values to the component function handleInput: Uncaught TypeError: Cannot read property 'bind' of undefined However, when I insert the input element into the return statement at the bottom of the render method, it doesn't produce any errors. I'm guessing that this has something to do with the lifecycle of the render method, but I'm not sure. Any insight is appreciated. As for what the code does, it retrieves a string from this.props.info.text and

Binding methods in react components

假如想象 提交于 2021-02-11 04:56:22
问题 I'm getting an error when I try to bind values to the component function handleInput: Uncaught TypeError: Cannot read property 'bind' of undefined However, when I insert the input element into the return statement at the bottom of the render method, it doesn't produce any errors. I'm guessing that this has something to do with the lifecycle of the render method, but I'm not sure. Any insight is appreciated. As for what the code does, it retrieves a string from this.props.info.text and

Typescript baseUrl not working in React Typescript project

孤街醉人 提交于 2021-02-11 04:31:35
问题 I defined the baseUrl in my tsconfig.json file: "baseUrl": "src", In .eslintrc.js I have: parser: '@typescript-eslint/parser', parserOptions: { ecmaFeatures: { jsx: true, }, ecmaVersion: 2018, sourceType: 'module', project: './tsconfig.json', }, Now in e.g. index.tsx I can import my components like import Layout from 'components/layout'; When I run gatsby develop I get some errors like: If you're trying to use a package make sure that 'components/layout' is installed. If you're trying to use

Typescript baseUrl not working in React Typescript project

早过忘川 提交于 2021-02-11 04:31:33
问题 I defined the baseUrl in my tsconfig.json file: "baseUrl": "src", In .eslintrc.js I have: parser: '@typescript-eslint/parser', parserOptions: { ecmaFeatures: { jsx: true, }, ecmaVersion: 2018, sourceType: 'module', project: './tsconfig.json', }, Now in e.g. index.tsx I can import my components like import Layout from 'components/layout'; When I run gatsby develop I get some errors like: If you're trying to use a package make sure that 'components/layout' is installed. If you're trying to use

React not rendering the view on mobile browser when fetching data from API

試著忘記壹切 提交于 2021-02-11 04:30:50
问题 I noticed something strange today when I accessed my localhost from my mobile phone that are both on same network (wifi). The thing is the page is not being rendered on my phone and the page shows blank, while it works pretty fine on my computer. Here is the code: import React, {Component} from 'react'; import './assets/css/bootstrap.min.css'; // import './assets/js/bootstrap.min'; import { Timeline, Tweet} from 'react-twitter-widgets' import config from './config'; class App extends

Gatsby StaticQuery and Rendered HTML

£可爱£侵袭症+ 提交于 2021-02-11 04:30:43
问题 I'm struggling to find out how <StaticContent> behaves. If I disable javascript in my app, everything inside a <StaticContent> will not be rendered. Is this the intended behavior? There is a way to workaround it? A partial code sample: const Sample = (props: any) => ( <StaticQuery query={graphql` query { site { siteMetadata { siteTitle siteTitleShort } } } `} render={(data) => ( // THIS CODE WILL NOT BE RENDERED IF JAVASCRIPT IS DISABLED // YOU'LL NOT BE ABLE TO FIND IT BY LOOKING INTO THE

React not rendering the view on mobile browser when fetching data from API

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-11 04:29:28
问题 I noticed something strange today when I accessed my localhost from my mobile phone that are both on same network (wifi). The thing is the page is not being rendered on my phone and the page shows blank, while it works pretty fine on my computer. Here is the code: import React, {Component} from 'react'; import './assets/css/bootstrap.min.css'; // import './assets/js/bootstrap.min'; import { Timeline, Tweet} from 'react-twitter-widgets' import config from './config'; class App extends

This site can’t be reached docker-compose

强颜欢笑 提交于 2021-02-11 02:10:18
问题 I am trying to use docker-compose for react-typescript application with webpack-dev-server below is my Dockerfile FROM node:lts-slim RUN mkdir -p /usr/src/app WORKDIR /usr/src/app EXPOSE 3000 CMD [ "npm", "start" ] "start": "webpack-dev-server --port 3000" this package.json line docker-compose.yml version: "3" services: frontend: container_name: awesome_web build: context: ./client dockerfile: Dockerfile image: webpack ports: - "3000:3000" volumes: - ./client:/usr/src/app I executed command

This site can’t be reached docker-compose

依然范特西╮ 提交于 2021-02-11 02:02:21
问题 I am trying to use docker-compose for react-typescript application with webpack-dev-server below is my Dockerfile FROM node:lts-slim RUN mkdir -p /usr/src/app WORKDIR /usr/src/app EXPOSE 3000 CMD [ "npm", "start" ] "start": "webpack-dev-server --port 3000" this package.json line docker-compose.yml version: "3" services: frontend: container_name: awesome_web build: context: ./client dockerfile: Dockerfile image: webpack ports: - "3000:3000" volumes: - ./client:/usr/src/app I executed command

This site can’t be reached docker-compose

萝らか妹 提交于 2021-02-11 02:01:35
问题 I am trying to use docker-compose for react-typescript application with webpack-dev-server below is my Dockerfile FROM node:lts-slim RUN mkdir -p /usr/src/app WORKDIR /usr/src/app EXPOSE 3000 CMD [ "npm", "start" ] "start": "webpack-dev-server --port 3000" this package.json line docker-compose.yml version: "3" services: frontend: container_name: awesome_web build: context: ./client dockerfile: Dockerfile image: webpack ports: - "3000:3000" volumes: - ./client:/usr/src/app I executed command