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

cannot read property children of undefined #14

Closed
gilesbradshaw opened this issue Apr 11, 2016 · 2 comments
Closed

cannot read property children of undefined #14

gilesbradshaw opened this issue Apr 11, 2016 · 2 comments

Comments

@gilesbradshaw
Copy link

with

import React, {
  AppRegistry,
  Component,
  Image,
  StyleSheet,
  View,
  ListView,
  Navigator
} from 'react-native';

import Svg,{
    Circle,
    Ellipse,
    G,
    LinearGradient,
    RadialGradient,
    Line,
    Path,
    Polygon,
    Polyline,
    Rect,
    Symbol,
    Text,
    Use,
    Defs,
    Stop
} from 'react-native-art-svg';


var styles = StyleSheet.create({
  container: {
    flex: 1

  }
});

export default class MyApp extends Component {
  render() {

    // Just imagine we're getting loggedInUserID from some other part of the app.
    return(
      <View style={styles.container}>
        <Svg
                height="100"
                width="100"
            >
                <Circle
                    cx="50"
                    cy="50"
                    r="45"
                    stroke="blue"
                    strokeWidth="2.5"
                    fill="green"
                />
                <Rect
                    x="15"
                    y="15"
                    width="70"
                    height="70"
                    stroke="red"
                    strokeWidth="2"
                    fill="yellow"
                />
            </Svg>
          </View>);

  }
}

I get cannot read property children of undefined Svg.js @66:0

@gilesbradshaw
Copy link
Author

It doesn't like the arrow function in Svg.js :

if I replace

getChildren = ()=> {
        return Children.map(this.props.children, child => {
            return cloneElement(child, {
                svgId: this.id
            });
        });
    };

with:

getChildren = function(){
        return Children.map(this.props.children, child => {
            return cloneElement(child, {
                svgId: this.id
            });
        });
    };

it works!

@gilesbradshaw
Copy link
Author

I made a PR #15

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