question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using theme variables from getTheme and connectStyle

See original GitHub issue

Question: Is it possble to have a component use the variables that are injected into:

<StyleProvider style={getTheme(material)}>
    <App>
</StyleProvider>

As far as I can tell, connectStyle only allows you to add variables to your theme, it does not allow access to existing ones.

For example if my app looks like so:

<StyleProvider style={getTheme(material)}>
    <App>
</StyleProvider>

I want to be able to pull out the brandPrimary variable from our material injected theme like so:

<App>
    <Text style={this.props.style.brandPrimary>
         Some Text
    </Text>
</App>

export const connectStyle('NativeBase.Theme', {})(App);

Anyone know if this is possible?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:16
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
stale[bot]commented, Dec 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

2reactions
benzman81commented, Sep 4, 2018

Is there a solution to this? We followed the guide for a custom component, but now we want those styles to be overwritten by a variables.js file. Any hint or is this just not possible?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customize
What are themes and variables and how to change them? NativeBase comes with a theme folder which comprises of two sub-folders. components: Theme...
Read more >
How to use the native-base.getTheme function in native-base
getTheme examples, based on popular ways it is used in public projects. ... themeName]; const theme = getUserTheme(variables, customVariables); return ...
Read more >
javascript - Nativebase - customise a component
I fixed the error by using an empty getTheme() in the <StyleProvider> : const renderCategoryRow = (props, item) => { const styles1 ...
Read more >
How to create better themes with CSS variables
CSS variables let you define values for reuse throughout a CSS file , opening the door to more efficient theming capabilities — no ......
Read more >
Writing a Theme - Tutorials - Shoutem Developers
Here the app owner can customize your theme through theme variables. ... Also, import connectStyle from @shoutem/theme to connect the component to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found