How Can I Use Kitto (/Dashing) With A Standard React Fetch API? - reactjs

The Short Story:
How does Elixir/Kitto link its Ruby syntax with the React parts?
Context:
Hi there. I'm a newbie in a React-heavy dev team while from a non dev background - so still finding my feet, as you can imagine.
I've been asked to build a dashboard that uses API live-feed/data - using React. I imagined this as a cloud hosted app that uses fetch to get api data through and displays in React components.
We found Kitto online, it looks rather great.
https://github.com/kittoframework/kitto
But... here's the challenge: code-wise, a lot of it appears very very Ruby-like (though the components are React).
So i'm very confused. How can i use Kitto as a slick React dashboard, but fetch my api data in a React 'fetch' fashion, if a lot of the logic is in Ruby? Or something very similar?
Or more specifically:
How do the .html.eex Elixir files talk to the api / React components?

Related

How can I embed a react page or component inside a flutter-web app?

I want to embed an unhosted react page (or a react component with some fancy 3rd party graph library) inside a flutter-for-web app. Why? I am think the react graph app I have is much nicer than what I can do in flutter (using the existing 3rd party packages) and so it might be good if I could just embed that react stuff inside a flutter-for-web app until I can do in flutter what I already have in react.
There is a flutter package (flutter_inappwebview) that can do this for mobile but I need to do it for a web app. I need to pass data back and forth between the react stuff and the flutter stuff too, so for instance the react graph will take in its data from flutter - not direct from the network or DB - and after drawing its pretty pictures and some user interaction will be able to send data back to my flutter code.
Is this easy? Already done in another package I haven't found yet? I know I can interop with javascript but just using #JS to interact with the react package (along with maybe some redux or maybe another basic state management) solution just sounds like it might be a tricky job.
Thanks

How can i use my react component as a web component with just a javascript tag call

I am working on a react app with mapbox that gets data from a JSON file and adds the data on the app.. I have successfully built the app. But what I want now is that I want to be able to use my react-app as a web component. In a way that it will be usable in websites and web apps.
Think of it this way:
Your React application is the U-Haul truck that delivers everything from the Web Server (Back-End) to the Browser (Front-End)
Now you say you want everything wrapped in a (native) Web Component:
<move-house></move-house>
It is do-able, but you as the Developer have to develop all dependencies
It starts by fully understanding what React is and does, so you can wrap all its behaviour.
Unlike other Frameworks (Angular, Vue, Svelte) React has no "Make-it-a-Web-Component" option,
because React, with its virtual DOM, is a totally different (and rather outdated) beast that doesn't comply with modern Web Standards. (today [Dec2020] React only scores 71% on the Custom Elements Everywhere test)
See: https://custom-elements-everywhere.com/libraries/react/results/results.html
for what you as the developer have to fix, because React does not do that for you
Some say React compared to modern JavaScript technologies, Frameworks, Web Component libraries like Lit and Stencil or Svelte, is more like:
It is possible in react using direflow. https://direflow.io/

Angular Services in ReactJS?

I am new to ReactJS and I'm working on the Front-End side of a project I have developed myself. The project is meant to be a site where users can logIn and post messages.
I have developed my back-end using Spring, Kotlin and MongoDB as DDBB, and have developed the API to perform all the necessary actions.
I have already developed the front-end side in Angular 6, since I know how to do that, and I have the site running correctly.
However, I'm trying to learn ReactJS, and I want to 'replicate' what I've done in Angular with React. After some tutorials and stuff, I have been able to develop my LoginComponent, which can fetch correctly the userInformation from the backend.
Here's then my question: In Angular, I use services to store variables that I may need from different routes, such as the userId (I will query the messages using that). I have not noticed how to do that in React, any idea?
Sorry for the poor explanation, I'm new to React.
You need a place to store the application state, you can use rxjs or mobx observables, or you can use redux. I personally like observables, as there is a lot of boilerplate in redux.
In react, your smart components will usually import pure functions from services that perform actions on the stores, and derive its rendering from the application state that is passed down to dumb rendering components.

React and React Native archetypal model

What is a good approach for making a React web and a React Native app that share their APIs for consuming the same database?
The system will have some CRUD screens for managing products and their images as well diferent events that the user will save.
I will follow the component / container pattern with Redux to be able to reuse code.
I am working in Windows SO.
I was thinking in:
NodeJs (APIs) and Heroku server
MongoDB
React (web app)
React Native (mobile app)
Are there some common archetypal model when using React and React Native consuming the same apis and DB?
I know I'm going to get flamed for this one....Even though it's not persistant to what you asked. I started a new project where we are using Firebase as our cloud backend and it works seamlessly between the web, ios, and android versions (building in react native).
But in regards to your question, react and react-native work well together, You can setup your redux actions (in react-native) almost identical to your react web app. The only differences between how you want to query your backend and handle auth (native uses asyncStorage vs localstorage/cookies). React native has a built in Fetch vs any other React package like Axios or SuperAgent.

React + React Native starter kit

I am going to develop a web + mobile application using React and React Native. I'd like to share as much code as possible between React and React Native. I was looking for some starter kits, but found only este. However, for me, it seems to be an overkill as it has too many dependencies (also I wasn't able to make it work for Android - when I fix some error, I run into another one).
I'd like to have just React + React Native + Redux + web bundling etc. Are there any other alternatives? Or at least very simple example apps that I could use?
Did you check the awesome React-native list ?
As I said in this thread, as long as you follow the component / container pattern with Redux; you are able to reuse a lot of code.
The pattern encourages you to separate every presentational code into the comopnent. The container holds all the logic.
Then when you want to reuse the code, you just have to rewrite the component.
Here is a great explanation on how to implement it.
Also, you may want to check React-native-web. It allows you to code in react-native for the .... browser.
Update: I now know why there aren't almost any starter kits that would combine React + React Native. The reason is that it is not a good idea to combine web React and React Native. Just create two separate apps, you'll save yourself a lot of headaches. For those still interested in combining the two platforms, have a look at React Native for Web instead.
So in the end, I've created my own started kit. You can find it here: https://github.com/gina-system/react-starter
why do not you check out https://github.com/teallabs/react-native-init
pretty amazing react-native starter kit with codepush, google signin, sentry, react-navigations and all setup steps.

Resources