Emre Tapcı
Emre Tapcı

Reputation: 1908

ReactJS component cannot resolve a domain name

When I use a component like

const React = require('react');
const dns = require('dns');

class DnsResolver extends React.Component {
    componentDidMount() {
        dns.resolve('https://www.google.com', (err, addresses) => {
            this.setState({
                address: addresses
            });
        });
    }

    render() {
        return (
            <div>
                {this.state.address}
            </div>
        );
    }
}

module.exports = DnsResolver;

the result is 0.0.0.0. Somehow, the browser cannot resolve the address. Why might this happen?

Upvotes: 1

Views: 666

Answers (1)

Fernando Montoya
Fernando Montoya

Reputation: 2644

dns is a native NodeJS module, it is intended to use in the server.

Upvotes: 2

Related Questions