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.

TypeError: Cannot read property 'push' of null when using SvgXml with babel plugin import

See original GitHub issue

Hello. I don’t know if I’m using this library wrong or what but I only get “TypeError: Cannot read property ‘push’ of null” whenever I am trying to use an SvgXml tag.

babel.config:

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [['babel-plugin-inline-import', { extensions: ['.svg'] }]],
};

MyComponent.js

import React from 'react';
import { View, StyleSheet, Text } from 'react-native';
import { SvgXml } from 'react-native-svg';
import MyIcon from '../assets/icons/MyIcon.svg';
import CustomText from './CustomText';

const styles = ...

const MyComponent = ({ text }) => {
  return (
    <View style={styles.header}>
      <SvgXml width={100} height={200} xml={MyIcon} />
      <CustomText italic style={styles.label}>
        {text}
      </CustomText>
    </View>
  );
};

export default MyComponent;

What am I doing wrong? Thanks in advance

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

6reactions
msandcommented, Mar 8, 2020

Probably babel conf error, closing.

4reactions
msandcommented, Mar 29, 2020

Well nothing to do unless there’s a repro, instructions in readme are quite clear and seem to work just fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'push' of null when using SvgXml with ...
This is a clean project, only installed what was needed for this package and the babel plugin. import { View } from 'react-native';...
Read more >
TypeError: Cannot read property 'push' of null in react js
Here problem is you are storing blank array with key as transactions , but you are fetching data key transations .
Read more >
import { svgXml } from "react-native-svg"; Code Example
import SvgUri from 'react-native-svg-uri'; // SVG Package ... reactjs typeError: Cannot read property 'offsetHeight' of null ...
Read more >
Uncaught TypeError: Cannot read property 'push' of undefined
Uncaught TypeError: Cannot read property 'push' of undefined. Hey,. I am trying to serve random words to the user but only serve each...
Read more >
package.json - Mend Renovate Dashboard
webpackJsonp||[]).push([[0],{455:function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.r(__webpack_exports__) ...
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