jpudysz / react-native-unistyles

Level up your React Native StyleSheet
https://unistyl.es
MIT License
1.55k stars 42 forks source link

Theme Context Not Found in Storybook for Web Platform #293

Closed iam047 closed 2 months ago

iam047 commented 2 months ago

Description

When using theme variables in Storybook for Web Platform, an error occurs as shown in the screenshots. However, the library works fine without theme variables. This suggests there might be an issue with accessing the theme or that additional setup is needed for Storybook to handle theme variables properly.

With using theme.margins.xl from theme

image

Without theme variables

image

Steps to reproduce

  1. Create an empty project with Storybook. You can use the following command with a ready-made template: npx create-expo-app --template expo-template-storybook AwesomeStorybook
  2. Integrate react-native-unistyles into the project.
  3. Launch Storybook for the web platform.

I've also created a repository with this issue and included a link.

Snack or a link to a repository (optional)

https://github.com/iam047/AwesomeStorybook

Unistyles version

2.9.2

React Native version

0.73.6

Platforms

React Native Web

Engine

Hermes

Architecture

Paper (old)

jpudysz commented 2 months ago

Hey, I don't have any knowledge or tips on how to integrate Storybook, but I know that others have been successful. Currently, I don't have the bandwidth to look into this third-party integration. The only tip I have is to ensure that Unistyles are initialized. If it works fine in the browser, it should also work in Storybook. Also, please check the "Discussions" and "Issues" sections you'll find tips from other developers.

If you find the root cause, I'm happy to accept the PR / patch it.