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.

Uncaught Invariant Violation: SearchkitProvider.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

See original GitHub issue

I’ve been playing with the searchkit components and have been receiving errors regarding Searchkit Provider.render().

Simple case of mine:

import {
    SearchkitManager,
    SearchkitProvider,
    InitialLoader,
      ...
    } from "searchkit";

const InitialLoaderComponent = (props) => (
  <div className={props.bemBlocks.item().mix(props.bemBlocks.container("item"))}>
    loading please wait...
  </div>
)

class ConApp extends React.Component {

...

 render() {

    const searchKitManager = new SearchkitManager('setup-is-here')


    return (<SearchkitProvider searchkit={searchKitManager}>
            <InitialLoader component={InitialLoaderComponent}/>
        </SearchkitProvider>)

Gives:

Uncaught Invariant Violation: SearchkitProvider.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

Another case:


class ConApp extends React.Component {

...

 render() {

    const searchKitManager = new SearchkitManager('setup-is-here')


    return (<SearchkitProvider searchkit={searchKitManager}>
            <SearchBox />
        </SearchkitProvider>)

Gives:

Uncaught Invariant Violation: SearchkitProvider.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

Aside from those, the only component that seems to work is <Hits />. Any idea why these simple components are not working? And why <Hits /> seems to work?

Some notes: -I am using es6, not tsx -I am not importing react or react-dom in THIS script directly -<Hits /> provides no styling even though styles are included (this might be default?)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
devlesedicommented, Jun 4, 2016

I had the same multiple copies of React error. Adding an alias, as @nirchernia suggested, solved the problem. For anyone having the same issue, add this to your webpack config file. resolve: { alias: { react: path.resolve('./node_modules/react') } }

0reactions
ssetemcommented, Jun 4, 2016

thanks @devlesedi

We should probably start a FAQ and add advice like this into it

Read more comments on GitHub >

github_iconTop Results From Across the Web

A valid React element (or null) must be returned. You may ...
You may have returned undefined, an array or some other invalid object. Here's my code: import React from 'react'; import ReactDOM ...
Read more >
A valid React element (or null) must be returned. · Issue #1521 ...
You may have returned undefined, an array or some other invalid object. I found that v 1.6.0 still works well, and this error...
Read more >
Error Decoder - React
Foo.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object. Installation....
Read more >
"A valid React element (or null) must be returned. You may ...
Coding example for the question Why this error is showing: "A valid React element (or null) must be returned. You may have returned...
Read more >
Objects are not valid as a React child React error | bobbyhadz
The React.js error "Objects are not valid as a React child" occurs when we try to directly render an object or an array...
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