strophe / strophejs

Strophe.js is an XMPP library for JavaScript

Home Page:http://strophe.im/strophejs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"node.querySelector is not a function" after CONNECTING with React Native

karthikeayan opened this issue · comments

Using strophejs with React Native. My code looks like below,

window.DOMParser = require('xmldom').DOMParser;
window.document = new DOMParser().parseFromString("<?xml version='1.0'?>", 'text/xml');
import './lib/strophe.js'
const Strophe = window.Strophe;

export default class App extends React.Component {
  constructor(){
    super();
    this.state = {
      connection: null
    }
  }

  onConnect(status){
    console.log(status)
  }

  componentWillMount(){
      const connection = new Strophe.Connection("http://<my_ejabberd>:5280/http-bind");
      connection.connect("user", "pass", this.onConnect);
      // connection.disconnect()
      this.setState({
        connection: "empty"
      })
  }

console.log printing "1" which is CONNECTING status. After few seconds, am getting "node.querySelector is not a function".

commented

A more specific error message would be helpful. In which line does the error occur? Can you set a break point at that location and check the value of node? Also enable debugging for strophe and post the output.

@sualko how to integrate it , any help from you?
my code:

import React, { Component } from 'react';
import { Text, View } from 'react-native';
import {Header,Left,Icon} from 'native-base';
window.DOMParser = require('xmldom').DOMParser;
window.document = new DOMParser().parseFromString("", 'text/xml');
import '../library/strophe';
const Strophe = window.Strophe;;

im getting error while
bundling failed: Error: E:\react\octacat\library\strophe.js:6395:0: calls to require expect exactly 1 string literal argument, but this was found: require(["strophe-polyfill"]).

commented

@akshgods 1 Problem = 1 Issue 😉. Please also see my post in the other issue, but I have no expierence with Strophe in React. Sorry.