Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not change dark theme in ViewNativeComponent #461

Open
chanphiromsok opened this issue Dec 20, 2024 · 8 comments
Open

can not change dark theme in ViewNativeComponent #461

chanphiromsok opened this issue Dec 20, 2024 · 8 comments

Comments

@chanphiromsok
Copy link

Description

import View from "react-native/Libraries/Components/View/ViewNativeComponent"; not work
import { View } from "react-native"; work fine

Screen.Recording.2024-12-20.at.13.31.55.mov

Steps to Reproduce

  1. click try change theme

Snack or Repository Link (Optional)

https://github.com/chanphiromsok/asdf-tr

Unistyles Version

3.0.0-beta.4

React Native Version

0.76.5

Platforms

Android, iOS

Expo

Yes

@chanphiromsok
Copy link
Author

chanphiromsok commented Dec 20, 2024

if I patch the import from node_modules/react-native/Libraries/Components/View/View.js
I think this issue might relate to unistyle babel

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @format
 * @flow strict-local
 */


import ViewNativeComponent from './ViewNativeComponent';
module.exports = ViewNativeComponent;

change the theme is work fine you can see the image
image

Video

Screen.Recording.2024-12-20.at.13.57.34.mov

@jpudysz
Copy link
Owner

jpudysz commented Dec 20, 2024

Babel plugin looks for React Native components based on import from 'react-native'. This is currently not supported as you import from nested path.

@chanphiromsok
Copy link
Author

will support enable whiteList babel in the future ?

@chanphiromsok
Copy link
Author

I want to report issue one more with dark theme
toggle appearance not working with declare variable

// Not Working 
  const mergedStyles = [styles.container(flex, props.bgColor), styles.box];
  return <View style={mergedStyles}/>

/// Working
<View style={[styles.container(flex, props.bgColor), styles.box]}>

image

@jpudysz
Copy link
Owner

jpudysz commented Dec 20, 2024

will support enable whiteList babel in the future ?

I'm not sure, this is private path, why do you import View from this path?

toggle appearance not working with declare variable

Thanks, I'm aware of it. There is no flatMap underneath, so it won't work with beta4. I'm working on #438 to remove any issues with array, styles, spreading etc.

@chanphiromsok
Copy link
Author

will support enable whiteList babel in the future ?

I'm not sure, this is private path, why do you import View from this path?

toggle appearance not working with declare variable

Thanks, I'm aware of it. There is no flatMap underneath, so it won't work with beta4. I'm working on #438 to remove any issues with array, styles, spreading etc.

thank you for now I plan to use unistyle and I want to explore and apologize there are many report to you

@todorone
Copy link

will support enable whiteList babel in the future ?

I'm not sure, this is private path, why do you import View from this path?

This is common practice nowadays to use lean View and Text components rather then bloated RN's in-house components to improve performance. [Example]

Can we consider making babel plugin customisable to set custom import paths like @/ui/View/@/ui/Text? @jpudysz

@jpudysz
Copy link
Owner

jpudysz commented Dec 20, 2024

At some point probably, but for now I want to make it work with basic setups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants