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.

Could we port Grommet to React Native using primitives?

See original GitHub issue

Expected 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 and react-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:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
italomlpcommented, Apr 3, 2019

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.

1reaction
macintoshhelpercommented, Apr 1, 2020

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-react

What I would suggest from my findings, is having a @grommet/primitives package that exports styled-components (exporting the ThemeProvider, 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

let styled;

if (Platform.OS === 'web') {
  styled = require('styled-components');
} else {
  styled = require('styled-components/primitives');
}
const { ThemeProvider } = styled;

export { styled, ThemeProvider };

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 uses react-native-web for styling, which messes up SSR and creates quite a bit of bugginess. styled.div should be used on web, and styled.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.

Read more comments on GitHub >

github_iconTop 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 >

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