Skip to content

Commit

Permalink
Merge pull request styled-components#1391 from stratiformltd/warn_on_…
Browse files Browse the repository at this point in the history
…react_native

Add warning if importing Web Styled Components on React Native
  • Loading branch information
kitten authored Dec 27, 2017
2 parents f588fde + fa02e00 commit 4ed8b69
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file. If a contri

- Fixed nested themes not being republished on outer theme changes, thanks to [@Andarist](https://github.com/Andarist) (see [#1382](https://github.com/styled-components/styled-components/pull/1382))

- Add warning if you've accidently imported 'styled-components' on React Native instead of 'styled-components/native', thanks to [@tazsingh](https://github.com/tazsingh) (see [#1391](https://github.com/styled-components/styled-components/pull/1391))

## [v2.4.0] - 2017-12-22

- remove some extra information from the generated hash that can differ between build environments ([see #1381](https://github.com/styled-components/styled-components/pull/1381))
Expand Down
13 changes: 13 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ import ThemeProvider from './models/ThemeProvider'
/* Import Higher Order Components */
import withTheme from './hoc/withTheme'

/* Warning if you've imported this file on React Native */
if (
process.env.NODE_ENV !== 'production' &&
navigator &&
navigator.product === 'ReactNative'
) {
console.warn(
"It looks like you've imported 'styled-components' on React Native.\n" +
"Perhaps you're looking to import 'styled-components/native'?\n" +
'Read more about this at https://www.styled-components.com/docs/basics#react-native',
)
}

/* Instantiate singletons */
const ComponentStyle = _ComponentStyle(
generateAlphabeticName,
Expand Down

0 comments on commit 4ed8b69

Please sign in to comment.