TypeError: Cannot read property 'brandPrimary' of undefined
See original GitHub issuereact-native, react and native-base version
"react": "16.2.0",
"react-native": "0.53.0",
"native-base": "^2.3.7",
Expected behaviour
The Jest test suite is expected to run & tests pass
Actual behaviour
TypeError: Cannot read property 'brandPrimary' of undefined
at Object.<anonymous> (node_modules/native-base/src/theme/variables/platform.js:196:20)
at Object.<anonymous> (node_modules/native-base/dist/src/theme/components/Body.js:1:112)
at Object.<anonymous> (node_modules/native-base/src/theme/components/index.js:2:1)
Steps to reproduce (code snippet or screenshot)
- Create a simple component like:
import React, { Component } from 'react';
import { Footer, Text, Left, Body, Right } from 'native-base';
class SimpleComponent extends Component {
render() {
const { leftText, rightText } = this.props;
return (
<Footer>
<Left>
<Text>{leftText}</Text>
</Left>
<Body/>
<Right>
<Text>{rightText}</Text>
</Right>
</Footer>
);
}
}
export default SimpleComponent;
- Add a simple test:
describe('Components | SimpleComponent', function () {
let wrapper;
const leftTest = 'Text';
beforeEach(() => {
wrapper = shallow(<SimpleComponent leftTest={leftTest}/>);
});
it('renders leftText', function () {
expect(wrapper.find(Text).text()).to.eq(leftTest);
});
});
- yarn test / npm test
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:15 (5 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property displayQuestion of undefined
Here is my code below, all I am trying to do is have it select one of the random questions, prompt the user...
Read more >[highcharts-more] Cannot read properties of undefined ...
Any ideas? Code: Select all TypeError: Cannot read properties of undefined (reading 'forEach') at t.<anonymous> (/_next/ ...
Read more >ERROR TypeError: Cannot read property title of undefined
HEY, SET YOUR LIKE THERE ! ... Your browser can't play this video. ... Solved: ERROR TypeError : Cannot read property title of...
Read more >Cannot read properties of undefined' - JavaScript Debugging
JavaScript Tutorial. How To Fix 'Uncaught TypeError : Cannot read properties of undefined ' - JavaScript Debugging. 25K views 6 months ago.
Read more >Restyle for React Native (vs Styled System) - Ryosuke
It displayed an error Uncaught TypeError: Cannot read property 'defaults' of undefined which didn't help. I tried adding the example text ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To solve this issue, just replace this :
by this :
in files
native-base-theme/variables/platform.js
andnative-base-theme/variables/material.js
at line196
.This is due to the fact that you cannot access an object property while declaring it. So, in my solution, i am using a computed property, which will be evaluated at runtime.
I can do a PR if you want.
@panuhorsmalahti In a day or two