question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Render only in client side

See original GitHub issue

is it possible to trigger render only in client side, not on the server i’m trying to use this example (google map) http://tomchentw.github.io/react-google-maps/async/

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the undefined component.

my goal is to load the google map library and then render the map on the client side only

Any help?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
NourSammourcommented, Feb 16, 2016

@OkuraSt try this

export default class MyMap extends Component {
  state = {
    inBrowser: false
  };
  componentDidMount() {
    this.setState({ inBrowser: true });
  }
  render() {
    if (this.state.inBrowser) {
        res = this.renderMap();
    } else {
      res = <span>Loading</span>;
    }
    return res;
  }
}
2reactions
Dattayacommented, Jan 25, 2016

@NourSammour I don’t think you need __CLIENT__ inside componentDidMount 'cause componentDidMount is only called on the client. Try to do it like so:

...
  state = {
    scriptjsLoaderEnabled: false
  };

  componentDidMount() {
    // initialize the lib here?
    // ...
    this.setState({scriptjsLoaderEnabled: true})    
  }

  render() {
    if (!this.state.scriptjsLoaderEnabled) {
      return (<div/>);
    }
    return (
      <ScriptjsLoader ... )
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Render client-side only component in Next.js
When the code got handed over to the browser, React suddenly recognised the fact something needs to be rendered, and it does just...
Read more >
How to use client-side only packages with SSR in Gatsby and ...
This is how client-side rendering works: Your browser requests a page, gets a nice block of code, pulls out his tools (Javascript, in...
Read more >
Client Side Rendering Vs Server Side Rendering in React js ...
In server-side rendering when a user makes a request to a webpage, the server prepares an HTML page by fetching user-specific data and...
Read more >
Rendering on the Web
Client -Side Rendering (CSR) #​​ Client-side rendering (CSR) means rendering pages directly in the browser using JavaScript. All logic, data ...
Read more >
Client-side Rendering - Patterns.dev
In Client-Side Rendering (CSR) only the barebones HTML container for a page is rendered by the server. The logic, data fetching, templating and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found