小编joe*_*mow的帖子

如何在我的 React 应用程序中添加 Intercom 脚本?

我正在使用 redux-segment 进行分析,并且正在尝试实施 Intercom。我遇到的问题实际上是让它加载等。我正在尝试遵循此方法,但仍然不确定在哪里输入应用程序 ID 等。 对讲段。我想在抓取当前用户时在我的动作创建器中加载对讲机,但没有关于如何实际加载对讲机的文档。

import { EventTypes } from 'redux-segment';

export function currentUser() {

  const request = user.current(); //this correctly grabs current user.

  if(request == null) {
     //having trouble with this part. load intercom non user specific
  } else {
     load intercom user specific
  }

  return {
    type: CURRENT_USER,
    payload: request
  };
}
Run Code Online (Sandbox Code Playgroud)

reactjs intercom

8
推荐指数
2
解决办法
9707
查看次数

Spotify Player尝试播放歌曲时抛出歧义错误

我正在尝试使用Spotify API播放歌曲,我发现了Spotify permium,但是当我尝试运行下面的代码时,出现错误 Optional(Error Domain=com.spotify.ios-sdk.playback Code=1 "The operation failed due to an unspecified issue." UserInfo={NSLocalizedDescription=The operation failed due to an unspecified issue.})

func initalizePlayer(authSession: SPTSession) {
        if self.player == nil {
            self.player = SPTAudioStreamingController.sharedInstance()
            self.player!.playbackDelegate = self
            self.player?.delegate = self
            try! player!.start(withClientId: clientId)
            self.player!.login(withAccessToken: authSession.accessToken)
            print("done initalizing")
        }
    }

    public func play() {
        player?.playSpotifyURI("spotify:track:7FOJvA3PxiIU0DN3JjQ7jT", startingWith: 0, startingWithPosition: 0, callback: { (error) in
            if error != nil {
                print(error)
                return
            }
        })
    }
Run Code Online (Sandbox Code Playgroud)

spotify ios swift

6
推荐指数
0
解决办法
207
查看次数

谷歌地图反应没有出现

我正在尝试使用google-map-react,但是当我尝试渲染它时,什么也没有出现。我错过了什么吗?

import GoogleMap from 'google-map-react';
import React, { Component } from 'react';

class GMaps extends Component {



static defaultProps = {
    center: {lat: 59.95, lng: 30.33},
    zoom: 11
  };

render() {
  return (
   <div>
    <GoogleMap
       style={{width: "100%", height: "500"}}
       defaultCenter={this.props.center}
       defaultZoom={this.props.zoom}
     />
   </div>
  )
} 


}
Run Code Online (Sandbox Code Playgroud)

reactjs

5
推荐指数
2
解决办法
9163
查看次数

使用新代码更新Docker映像

我在理解docker的这一部分时遇到了麻烦。我花了许多天做了这项研究,并横跨东西来了,如同docker-composedocker container commit。如果我有一个映像,并且对我的代码库进行了更改,那么如何通过代码更改来更新我的Docker映像?我以为Dockerfile应该可以解决这个问题,但是它对我不起作用。任何帮助表示赞赏。

docker docker-compose

5
推荐指数
3
解决办法
9497
查看次数

Redis 在 docker 容器中无故关闭

我正在尝试使用 docker-compose 启动一个 redis docker 容器,但我总是收到此错误。这是我的 docker-compose 运行命令docker-compose -f docker-compose.yml builddocker-compose -f docker-compose.yml up -d --force-recreate. 我正在 aws ecs 上运行 docker 容器并使用 t2.micro ec2 实例。我不确定这是否是原因。任何见解都会有所帮助。

我还包括了我的 docker-compose.yml

version: '2.1'

services:
  redis:
    image: redis:latest
    container_name: redis
    volumes: 
      - redis_data:/data
    ports: 
      - 6379:6379
  app:
    image: custom_image
    build: .
    depends_on:
      redis:
        condition: service_started
    ports:
      - 8003:8003
    links:
      - redis
volumes:
  redis_data:
Run Code Online (Sandbox Code Playgroud)

错误

1:C 11 Sep 00:18:34.345 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 11 Sep 00:18:34.348 # Redis version=4.0.11, …
Run Code Online (Sandbox Code Playgroud)

amazon-ecs redis docker docker-compose

5
推荐指数
1
解决办法
2072
查看次数

为什么我的多对多关系字段未定义?

我正在尝试创建一个关注者/关注系统,当我尝试将新用户附加到以下列表时,出现错误Cannot read property 'push' of undefined。这最终会创建 2 个单独的表,一张用于关注其他用户的用户,一张用于被其他用户关注的用户。不知道为什么它没有占据这个领域?任何帮助表示赞赏。

import { Length } from "class-validator";
import {
    Column,
    CreateDateColumn,
    Entity,
    JoinTable,
    ManyToMany,
    OneToMany,
    PrimaryColumn,
    RelationCount,
    Unique,
    UpdateDateColumn
} from "typeorm";

export class User {

    @PrimaryColumn()
    public user_id: string;

    @Column()
    public first_name: string;

    @Column()
    public last_name: string;

    @Column()
    public email: string;

    @Column()
    public phone_number: string;

    @Column()
    public username: string;

    @Column()
    @CreateDateColumn()
    public created_on: Date;

    @Column()
    @UpdateDateColumn()
    public updated_at: Date;

    @ManyToMany((type) => User, (user) => user.following)
    @JoinTable()
    public followers: User[];

    @ManyToMany((type) …
Run Code Online (Sandbox Code Playgroud)

arrays typescript typeorm

4
推荐指数
1
解决办法
3638
查看次数

如何使用回调从外部函数返回jsx?

我正在尝试从我的render方法之外返回jsx。当没有api请求时,它可以工作,但是一旦我添加了请求并添加了回调,我就无法返回jsx。我该怎么做呢?renderLocations在我的render方法中被调用。

renderLocations() {
    this.Geo((coord) => {
          return this.state.location.map((location, index) => {
            return (
              <div>
               {coord}
              </div>
            );
          })
        })
    }
Run Code Online (Sandbox Code Playgroud)

callback reactjs

3
推荐指数
1
解决办法
3017
查看次数

Redux表单错误未定义

为什么验证函数未定义错误?我在日志中打印错误但在字段中未定义.当我尝试做field.meta.error时,我得到一个未定义的.我把它放在inputComponent之后的const中<input>.

const inputComponent = function(field) {
  return (
    <div>
      <input { ...field.input } type={field.type} placeholder={field.placeholder} className={field.className} />
    </div>
  );
}

class Test extends Component {

  render() {

    <div>
       <Field name="name" component={inputComponent} type="email" placeholder="Email" />
       <Field name="password" component={inputComponent} type="password" placeholder="Password" />
    </div>

  }


function validate(values) {
  const errors = {};

  if(!values.name) {
    errors.categories = "Name error";
  }

  if(!values.password) {
    errors.categories = "Password error";
  }

  return errors;
}

}

Test = reduxForm({
  form: 'NameForm',
  validate
}, null, null)(Test);

export default …
Run Code Online (Sandbox Code Playgroud)

reactjs redux-form

3
推荐指数
1
解决办法
1978
查看次数

为什么子组件没有随着父组件的状态更新?

我正在将我的父状态传递给我的子组件,但是当我在子组件中打印道具时,我获得了父组件的先前状态而不是最新状态。我很确定这是因为this.setState是异步的。

  handleClick(event) {
   const value = event.currentTarget.value;
   this.setState({ touched: value });
  }

 render() {
  return(
   <ChildComponent {...this.state} />
  )

 }
Run Code Online (Sandbox Code Playgroud)

reactjs

2
推荐指数
1
解决办法
2641
查看次数

为什么在this.state里面的数组连接不起作用?

我正在尝试在键下面的组件状态中的数组中添加渲染日期date,但它总是返回0.

constructor(props) {
    super(props);
    this.state = {
      dates: []
    }
  }

  componentWillMount() {
    this.renderDateComp()
  }

  renderDateComp() {
    for(var i = 0; i < 5; i++) {
      var dat = new Date(Date().valueOf());
      dat.setDate(dat.getDate() + i);
      this.setState({ dates: this.state.dates.concat(dat) });
      console.log(this.state.dates); //prints length of 0
    }
  }
Run Code Online (Sandbox Code Playgroud)

reactjs

1
推荐指数
1
解决办法
4347
查看次数

我会使用核心数据吗?

所以我有一个过程让用户拍照添加信息并上传到我的数据库.我的问题是我应该如何存储这些数据,以便可以通过我的所有控制器访问它们,当他们点击上传按钮时,它会将最终对象发送到服务器以添加到数据库中.我会使用核心数据吗?或者像结构?我只是想确保我正确地这样做.

ios swift

1
推荐指数
1
解决办法
136
查看次数

为什么在重新渲染时没有调用componentDidMount?

我有多个用于注册的模式,并且遇到问题.我总共有三个动作.首先是注册按钮,然后激活第一个注册模式以便用google或facebook注册,然后在完成之后,提供者无法收集的其他信息的模式将出现在预先填写的输入聚集形式提供者.我渲染应用程序时渲染两个模态,仅在单击注册按钮时显示它.我需要在完成facebook或google登录后调用componentDidMount,但是当我在app拳头开始时渲染模态时调用它.按钮命中动作减速器和减速器改变类型bool的状态以显示模态或不显示模态.

class HeaderRegisterButton extends Component {
   render() {
     return(
       <div>
         <Register1/>
         <Register2/>
       </div>
     );
   }
 }
Run Code Online (Sandbox Code Playgroud)

注册模式1

class Register1 extends Component {
   render() {
     return(
       <div>
        <button onClick={() => this.props.showRegister2()} /> //This would hit the action reducer to get initial info and change the bool to show register 1 to false and register 2 to true.
       </div>
     );
   }
 }
Run Code Online (Sandbox Code Playgroud)

注册模态2

import { reduxForm, Field, initialize } from 'redux-form';

class Register2 extends Component {

  componentDidMount() {
    hInitalize() //only called when …
Run Code Online (Sandbox Code Playgroud)

reactjs

0
推荐指数
2
解决办法
1万
查看次数

生成 10,000 个线程似乎不是正确的方法,有其他想法吗?

我正在尝试模拟一个去中心化系统,但在给定现实生活参数的情况下进行模拟时遇到困难。

真实世界:

  • 每个模块都有自己的计算机,并且通过网络进行通信
  • 可能有数十万个模块
  • 他们将相互沟通以执行特定的操作

模拟:

  • 每个模块都被视为自己的线程,因为它们是异步工作的
  • 无法真正生成超过 1,000 个线程
  • 线程与模块的比例为1比1

每个模块生成一个线程是正确的方法吗?从理论上讲,这似乎是正确的方法,但在实践中,它会遇到大约 1,000 个线程的限制。

multithreading distributed

0
推荐指数
1
解决办法
94
查看次数