FormidableLabs / react-native-zephyr

TailwindCSS-inspired styling library for React Native.
https://formidable.com/open-source/react-native-zephyr/
MIT License
347 stars 5 forks source link

Remove `StyleProvider` #29

Open gksander opened 2 years ago

gksander commented 2 years ago

What is this?

This PR removes the need to wrap your app in StyleProvider. The reason for this change is twofold:

  1. It's easier to setup if you don't have to wrap your app. I like that, and then dark mode just sort of "magically" works without the provider.
  2. I'm working toward a set of response utilities, where you can apply "classes" based on screen size. This will require a top-level WindowDimensions listener. I'd like to keep things as performant as possible, and not have to deal with Context values changing and triggering cascading re-renders.

This PR also adds a bunch of cleanup around tests.

gksander commented 2 years ago

Damn, just now seeing that RNW doesn't support Appearance.addChangeListener, so this is going to fail for RNW 😢

I'm torn on this. I really like this change to the API, but not supporting RNW is a real downside.

UPDATE!

Looks like Appearance.addChangeListener does exist, it just doesn't conform to RN's new API for change listeners (e.g., returning a remove method from the subscription). I've created a PR for RNW to support this.

atanaskanchev commented 11 months ago

LGTM? 🥇