将循环结构转换为json,Phoenix和React

时间:2016-09-30 14:50:10

标签: javascript json reactjs react-native phoenix-framework

您好我有将循环结构转换为JSON 错误。

这是有效的 Main.js

    componentWillMount(){

    const getSocket = () => {
        const url = config.local ? `ws://${config.host}/socket` : `wss://${config.host}/socket`
        const params = {guardian_token:"foobar"}

        return new Socket(url, {params: params});
    }

    this.socket = getSocket();
}

                        <Scene
                        key="profile"
                        title='Profile'
                        component={Profile}
                        queries={{user: () => Relay.QL`query { user } `,}}
                        hideNavBar={true}
                        icon={TabIcon}
                        materialIconName='perm-identity'
                        socket={this.socket}
                    />

Child.js

    componentWillMount(){
    /* Connect to the websocket */
    /* Maybe this should be passed down as a prop ? */
    this.props.socket.connect(); /*<------------*/
    let channel = this.props.socket.channel("notifications:" + this.props.user.id)
    channel.join()
        .receive("ok", resp => {console.log("ok")})
        .receive("error", resp => {console.log("Unable to join", resp)})

    channel.on("new:notification", () => this.props.relay.forceFetch());
}

但如果我改成这个

//this.props.socket.connect();

并添加Main

this.socket.connect();

我收到此错误https://imgur.com/a/3CUT7

0 个答案:

没有答案