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

Object doesn't support property or method 'map' #44

Closed
lostrouter opened this issue Nov 14, 2014 · 3 comments
Closed

Object doesn't support property or method 'map' #44

lostrouter opened this issue Nov 14, 2014 · 3 comments

Comments

@lostrouter
Copy link

I am trying out Reactjs.Net and i am running into an error. I have chosen to forgo using jsx in favor of plain JS. i am not sure if this is the cause of my problem, but i am following the compiled js examples i have found in the reactjs tutorials. array.map.js is the code found here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map. Do i have to use jsx?

the specific error
Error while rendering "BreadCrumbBox" to "react1": Object doesn't support property or method 'map'
Line: 8
Column:9

// SimpleReactor.js
var BreadCrumbBox = React.createClass({
    render: function () {
        var crumblets = this.props.crumbs.map(function (item, index) {
            return BreadCrumb({
                crumb: item,
                key: index
            });
        });
        return React.DOM.ul({}, crumblets);
    }
});


var BreadCrumb = React.createClass({
    render: function () {
        return React.DOM.ul({},
        React.DOM.a({
            href: this.props.crumb.Url.toString()
        }, this.props.crumb.Text));
    }
});

BreadCrumbBox = React.createFactory(BreadCrumbBox);
BreadCrumb = React.createFactory(BreadCrumb);

the above is my react script.

here is my react config

ReactSiteConfiguration.Configuration
            .AddScript("~/Scripts/array.map.js")
            .AddScript("~/Scripts/SimpleReactor.js");

here is my cshtml page

@using System
@using System.Web.Mvc
@using System.Web.Mvc.Ajax
@using System.Web.Mvc.Html
@using System.Web.Optimization
@using System.Linq
@using React
@using React.Web
@using React.Web.Mvc

@inherits System.Web.Mvc.WebViewPage<BreadCrumbModel>


@Html.React("BreadCrumbBox", new { crumbs = Model.Crumbs })

@section scripts{
    @Scripts.Render("~/Scripts/array.map.js")
    <script src="http://fb.me/react-0.12.0.js"></script>
    @Scripts.Render("~/Scripts/SimplerReactor.js")
    @Html.ReactInitJavaScript()
}
@lostrouter
Copy link
Author

nevermind. my model that i was passing in was an ienumerable and not an array.

@Daniel15
Copy link
Member

Out of curiosity, what was the IEnumerable being serialized as?

@lostrouter
Copy link
Author

i did not dig in far enough to see. I will check soon.

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

2 participants