Comments (3)
Thanks. Feel free to create a PR adding this to the README if you like.
from react-native-keep-awake.
This gives me the following error:
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Here is my code:
// __mocks__/react-native-keep-awake.js
const keepAwake = require('react-native-keep-awake');
keepAwake.activate = () => console.log('stay awake!');
keepAwake.deactivate = () => console.log('go to sleep!');
export default keepAwake;
I'm pretty new to Jest, so I may be doing something else wrong. Any help would be appreciated.
BTW, I am using "method 1" by placing <KeepAwake/>
in my render()
method.
from react-native-keep-awake.
I am not sure why this matters, but I solved this by using import
instead of require
:
// __mocks__/react-native-keep-awake.js
import keepAwake from 'react-native-keep-awake';
keepAwake.activate = () => console.log('stay awake!');
keepAwake.deactivate = () => console.log('go to sleep!');
export default keepAwake;
from react-native-keep-awake.
Related Issues (20)
- Error when release APK HOT 10
- Android - Build fail HOT 9
- react-native link error : buildSettings.LIBRARY_SEARCH_PATHS.push is not a function HOT 3
- Support for KeepAwake only when device is charging HOT 3
- Not working on iPhone X HOT 2
- Not working on Android 7.1 HOT 7
- Undefined is not an object (evaluating '_reactNative.NativeModules.KCKeepAwake.activate) at index.js:506 HOT 9
- Undocumented bheavior on app state transition HOT 1
- Idempotent behavior is undocumented HOT 1
- KeepAwake.activate() not working when running the app in Xcode. Is it worth mentioning this in readme? HOT 1
- Build file 'C:\Users\Xiaojiju\Desktop\YJJ2.0\node_modules\react-native-keep-awake\android\build.gradle' line: 3 HOT 2
- Always active for ios HOT 2
- Crashes on iOS 13 as must run on Main Queue HOT 1
- RN 0.60+ support and Android X HOT 6
- Typings not released HOT 1
- Shame to Deprecate and replace with Expo cruft HOT 1
- Doesn't work after opening fullscreen player
- New non expo fork with hooks support! HOT 23
- Cannot read property 'activate' of undefined IOS HOT 4
- Add to the depreciation notice to npm HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-keep-awake.