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.

Error: Missing definition for RecoilValue

See original GitHub issue

Started playing around with atomFamily and selectorFamily (thanks to @tony-go’s PR branch) but when trying to replace my individual atom and selector lookups with the associated family functions I am getting errors like: Error: Missing definition for RecoilValue: “questionFamily__1__withFallback”"

I am assuming this is developer error, but I’m not sure what I’m doing wrong. Here is what my atomFamily looks like.


const questionById = buildHash() // omitting for brevity, but it's what it looks like!
const questionState = atomFamily({
  key: "questionFamily",
  default: (id) => {
    const item = questionById[id]
    return {
      type: item.type,
      label: item.label,
      value: item.value
    }
  }
});

const questionDB = {
  questionSequence: [... all question ids in sequence ],
  questionState
}

export questionDB

I then put this in a ReactContext to be able to get to it from other components.

        <RecoilRoot>
          <SurveyContext.Provider value={questionDB}>
            {
              questionDB.questionSequence.map((id) => {
                return (
                  <Question  key={id}  questionId={id} />)
              })
            }
          </SurveyContext.Provider>
        </RecoilRoot>

Inside my Question component I have:

const Question = (props) => {

  const questionDb = useContext(SurveyContext)
  const id = props.questionId
  const [questionState, setQuestionState] = useRecoilState(questionDb.questionState(id))

  return ( /* components */)
}

It’s the useRecoilState line where the error is being thrown. Feels like I’m probably messing something up with variable scoping or by using the ReactContext to pass it around, but I’m not sure what the right way to fix it is.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Shmewcommented, May 23, 2020

I tried creating an atom whose default value was a promise which gave me an exception of selector is not defined when it tries to create the atomWithFallback. I suspect this is the root cause of this.

0reactions
sendittokeithcommented, Jun 22, 2020

Still getting this error when trying to use a Promise for default atom value:
my recoil version: “recoil”: “^0.0.8”,

recoil.development.js:200 Uncaught Error: Missing definition for RecoilValue: "undefined""
Read more comments on GitHub >

github_iconTop Results From Across the Web

What does "Did not retain recoil value on render, or committed ...
I am running some react-testing-library tests and getting warnings for Did not retain recoil value on render, or committed after timeout ...
Read more >
atom(options) - Recoil
An atom represents state in Recoil. The atom() function returns a writeable RecoilState object.
Read more >
Simplifying your application state management with Recoil
A hook that returns a tuple of current atom, or selector, value and a setter function for that atom or selector, as built-in...
Read more >
Reimplementing the core Recoil's APIs for fun and learning
in the case of Selectors, calling their set function (if defined) ... throw new Error("Already subscribed to Recoil Value"); ...
Read more >
Semileptonic form factors for $$B\rightarrow D^*\ell \nu $$ at ...
The first error is theoretical, the second comes from experiment and the ... the recoil value w, calculated from the different definitions.
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