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

Problem with styled componets #35

Open
yuriedmundo opened this issue Aug 23, 2020 · 5 comments
Open

Problem with styled componets #35

yuriedmundo opened this issue Aug 23, 2020 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@yuriedmundo
Copy link

I'm having trouble using this library with Styled Components, has anyone had this problem?

@heyman333
Copy link
Owner

heyman333 commented Aug 27, 2020

could you upload example code?

@TiagoDanin
Copy link

TiagoDanin commented Nov 5, 2020

Styled use px as default unit.

No working (Only styled)

export const Text = styled.Text`
  flex: 1;
  font-weight: bold;
  font-size: ${RFValue(18, 580)};
  opacity: 0.78;
`;

// index.js
<Text allowFontScaling>
          {text}
</Text>

Solution:

Working (Mix styled + react style)

// style.js
export const Text = styled.Text`
  flex: 1;
  font-weight: bold;
  opacity: 0.78;
`;

// index.js
<Text allowFontScaling style={{fontSize: RFValue(18, 580)}}>
          {text}
</Text>

@albertoammar
Copy link

Styled use px as default unit.

No working (Only styled)

export const Text = styled.Text`
  flex: 1;
  font-weight: bold;
  font-size: RFValue(18, 580);
  opacity: 0.78;
`;

// index.js
<Text allowFontScaling>
          {text}
</Text>

Solution:

Working (Mix styled + react style)

// style.js
export const Text = styled.Text`
  flex: 1;
  font-weight: bold;
  opacity: 0.78;
`;

// index.js
<Text allowFontScaling style={{fontSize: RFValue(18, 580)}}>
          {text}
</Text>

Your code is wrong, try this:

export const Text = styled.Text`
   flex: 1;
   font-weight: bold;
   font-size: ${RFValue(18, 580)}px;
   opacity: 0.78;
`;

@heyman333
Copy link
Owner

@TiagoDanin Have you tried? font-size: ${RFValue(18, 580)}px;

@TiagoDanin
Copy link

TiagoDanin commented Nov 17, 2020

Your code is wrong, try this:

@albertoammar it's not wrong... this is example of how some people expect can use ;)

I put a wrong example, thanks. Update now

@TiagoDanin Have you tried? font-size: ${RFValue(18, 580)}px;

Yes this also work! but dp is different from px, recommend use in style prop.

I don't see it as a problem, just commented so you could know why of no working with styled.

@heyman333 heyman333 added the help wanted Extra attention is needed label Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants