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

Using Wrapped Provider with React.createElement throws TypeError: Object [object Object] has no method 'toUpperCase' #74

Closed
kevzettler opened this issue Aug 27, 2015 · 3 comments

Comments

@kevzettler
Copy link

Following the example here
https://github.com/rackt/react-redux#react-router-013
I'm using a wrapped provider on my React Router handler

 <Provider store={store}>
     {() => <Handler {...ReactProps} routerState={routerState} />}
</Provider>

If I pass this to React.renderToString it renders correctly.

if I pass it to React.createElement it throws an error
TypeError: Object [object Object] has no method 'toUpperCase'

site-0 (err): 2015-08-27 01:32 +00:00: TypeError: Object [object Object] has no method 'toUpperCase'
site-0 (err):     at autoGenerateWrapperClass (/opt/site/node_modules/react/lib/ReactDefaultInjection.js:53:19)
site-0 (err):     at Object.getComponentClassForElement (/opt/site/node_modules/react/lib/ReactNativeComponent.js:59:49)
site-0 (err):     at validatePropTypes (/opt/site/node_modules/react/lib/ReactElementValidator.js:361:45)
site-0 (err):     at Object.ReactElementValidator.createElement (/opt/site/node_modules/react/lib/ReactElementValidator.js:408:5)

I'm using some 3rd party middleware that passes the wrapped handler to
React.renderToString(React.createElement())

I suspect this is because React is trying to get a type for the anonymous function {() => }

Do I have to use an anonymous function here? can I wrap it in some other component or something?

@gaearon
Copy link
Contributor

gaearon commented Aug 27, 2015

Can you please show code in some more context? It would help to see the specific failing line completely.

@gaearon
Copy link
Contributor

gaearon commented Aug 27, 2015

<Provider>...</Provider> is already an element. Passing this to createElement doesn't really make sense to me.

@gaearon
Copy link
Contributor

gaearon commented Aug 27, 2015

I suspect this is because React is trying to get a type for the anonymous function {() => }

This has nothing to do with what's inside <Provider> I think. Doing React.render(React.createElement(<div />)) will also fail because <div /> is already an element.

I'm using some 3rd party middleware that passes the wrapped handler to
React.renderToString(React.createElement())

Um, why? :-)

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