Could we port Grommet to React Native using primitives?
See original GitHub issueExpected Behavior
Hi there! I’m thinking in last days about to port Grommet to work on React Native too. Searching in the google, I found a way that can be used.
- Grommet uses styled-components ✔️ (half way over)
- What I would do (or someone else interested in it), is to adapt Grommet to use
styled-components/primitives
andreact-primitives
, so having universal and reusable components, on ReactJS and React Native
I believe that most of the main Grommet components can be ported with this. Then, I would like to hear your opinions and, as suggested by @oorestisime and @ShimiSun in Grommet Slack, I’m opening this issue to discuss about that.
Actual Behavior
Actually, Grommet doesn’t work in React Native.
URL
Here’s some links that can be useful:
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Grommet - Medium
An introduction to building a React app with Grommet. I jump at every chance to incorporate styling into a project.
Read more >Using Grommet In React Applications - Smashing Magazine
In this tutorial, we're going to learn how to use Grommet as a UI library for React applications. We'll use Grommet as a...
Read more >Is it a problem to make all React components class-based?
It is not a problem to make all class based React components - as long as it works for you and you can...
Read more >Awesome UI component library - GitHub Pages
UI component library which aims to bring a native desktop experience to the web, ... You can use it as a starting point...
Read more >Grommet integration with create-react-app - Stack Overflow
You can use grommet components, just make sure you have grommet installed as well :) This package was created to address this specific...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Of course, there are many differences between web and native. What I told is maybe react primitives and styled-components/primitives be a way to make it works.
However, like I said in the last comment, I was thinking about make a “theme”, with colors, spacements and more details that can be made, for NativeBase.
Hi, I‘ve been working on a UI library that’s similar to Grommet, but has cross-platform UI component primitives, with
react-sketchapp
as a primary focus (compiles to web and React Native also though): https://github.com/elemental-design/elemental-reactWhat I would suggest from my findings, is having a
@grommet/primitives
package that exportsstyled-components
(exporting theThemeProvider
,styled
function, etc to make sure the context remains consistent. It could export{ View, Text, ...etc }
It can work something like this:Pseudo-code from my import resolving system: https://github.com/elemental-design/elemental-react/blob/master/src/styled.ts
I had a quick look through #3029 and noticed that it uses
styled-components/primitives
, but I think this should be avoided for web, as it usesreact-native-web
for styling, which messes up SSR and creates quite a bit of bugginess.styled.div
should be used on web, andstyled.View
on native platforms.This shouldn’t be too difficult, the main limiting factor would probably be that Yoga doesn’t support CSS grid yet though.