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't make Linear Gradient RN to work #85

Open
trigonometric-act opened this issue Mar 2, 2022 · 2 comments
Open

Can't make Linear Gradient RN to work #85

trigonometric-act opened this issue Mar 2, 2022 · 2 comments

Comments

@trigonometric-act
Copy link

I installed react-native-linear-gradient in the mobile package json and react-native-web-linear-gradient into next js folder and modified next.config.js like this:
module.exports = withTM({
webpack(config) {
config.resolve.alias = {
...(config.resolve.alias || {}),
'react-native$': 'react-native-web',
'react-native-linear-gradient': 'react-native-web-linear-gradient',
}
config.resolve.extensions = [
'.web.js',
'.web.ts',
'.web.tsx',
'.tsx', '.ts', '.js',
...config.resolve.extensions,
]
return config
},
})

I get the following error:

nextrn\node_modules\react-native-linear-gradient\index.js:1
import { Platform } from "react-native";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:988:16)
at Module._compile (internal/modules/cjs/loader.js:1036:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.react-native-linear-gradient (C:\Users\guill\OneDrive\Documentos\GitHub\nextrn\packages\web-nextjs.next\server\pages\index.js:407:18)
at webpack_require (C:\Users\guill\OneDrive\Documentos\GitHub\nextrn\packages\web-nextjs.next\server\pages\index.js:23:31)
at Module.../components/src/AppHeader.web.tsx (C:\Users\guill\OneDrive\Documentos\GitHub\nextrn\packages\web-nextjs.next\server\pages\index.js:334:86)

@trigonometric-act
Copy link
Author

Solved by installing both dependencies in components directory.

@trigonometric-act
Copy link
Author

Suddenly react-native-linear-gradient stopped working again is intalled in components directory with react-native-web-linear-gradient next config:

const withTM = require('next-transpile-modules')(['components' ], {
resolveSymlinks: true,
})

module.exports = withTM({
webpack(config) {
config.resolve.alias = {
...(config.resolve.alias || {}),
'react-native$': 'react-native-web',
'react-native': 'react-native-web',
'react-native-linear-gradient': 'react-native-web-linear-gradient',
},
config.resolve.extensions = [
'.web.js',
'.web.ts',
'.web.tsx',
'.tsx', '.ts', '.js',
...config.resolve.extensions,
]
return config
},
})

I also would like help with oblador/react-native-vector-icons, I don't know how to configurate it properly with next js. Thank you

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