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

arrayed style is not working #123

Open
withel21 opened this issue Aug 22, 2023 · 0 comments
Open

arrayed style is not working #123

withel21 opened this issue Aug 22, 2023 · 0 comments

Comments

@withel21
Copy link

withel21 commented Aug 22, 2023

When using style prop, style can be an array as below.

const padding = { padding: 2};
const bigHeight = { height: 50};
const normalHeight = { height: 20};
const longWidth = { width: 200 };
const termWidth = { width: 70 };
const margin= { margin: 8 };

...

<SkeletonPlaceHolder >
    <View style={[padding, bigHeight, normalWidth, margin]} />
    <View style={[normalHeight, longWidth]} />
    <View style={[normalHeight, longWidth]} />
    <View style={[padding, bigHeight, longWidth, margin]} />
</SkeletonPlaceHolder>

In this case,

const style =
element.type?.displayName === SkeletonPlaceholder.Item.displayName
? getItemStyle(element.props)
: element.props.style;
cannot make following code get width & height from style.

So, I suggest like below.

    const style =
      element.type?.displayName === SkeletonPlaceholder.Item.displayName
        ? getItemStyle(element.props)
        : Array.isArray(element.props.style) 
        ? element.props.style.reduce((flattenStyle, value)=>({...flattenStyle, ...value}), {})
        : element.props.style;
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

1 participant