Cesium + React

Hello

does Cesium can be used with React?

And, can be used with React Native?

Many thanks

I’ve seen others in the community deploy CesiumJS apps on mobile phones with React Native, so it’s definitely possible. You might find this Cesium React article a good place to start:

https://cesium.com/blog/2018/03/05/integrating-cesium-and-react/

It talks about an unofficial wrapper library for making it easier to use CesiumJS in React, although not everything is exposed, so you may need to grab a reference to the underlying viewer object if you’re trying to do something that isn’t covered by that library.

Yep - we’re using Cesium + React in a couple different projects. I specifically wrote a couple posts about using Cesium with Webpack and React a couple years ago:

https://blog.isquaredsoftware.com/series/declaratively-rendering-earth-in-3d

Same basic principles apply now.

I recently ran across Resium, a complete Cesium wrapper library for React. Render React components like and , and it takes care of hooking a lot of stuff automatically.

Docs: https://resium.darwineducation.com/

Dear Mark,
I have been using Resium for a while which is amazing. But I still cant figure out how to set state in react using cesium. For example, Id like to setState inside an onTick callback function. If I do the traditional way, Cesium goes crazy. :frowning: Any pointers? Ill read your articles :smiley:

“goes crazy” really isn’t a clear statement of what’s happening :slight_smile:

There’s nothing special about setting state with React in relation to Cesium or Resium. If you’re having issues, best bet is to try creating a CodeSandbox or a Github repo that demonstrates this problem happening and share that.

1 Like