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.

Got TypeError: Object(...) is not a function when trying to import { selectorFamily } from "recoil"

See original GitHub issue

Developer Story

As a developer I want to use the selectorFamily helper function So that I can make asynchronous queries with parameters

Description

I am trying to make an asynchronous data query with parameters. So I am trying to use the selectorFamily helper. But when I try to import { selectorFamily } from "recoil", the application throws TypeError: Object(...) is not a function.

How to fix it

Maybe exporting the selectorFamily helper at the recoil library.

Steps to reproduce the behavior

  1. Initialize or open a React project;
  2. Run npm install recoil --save-exact to install version 0.0.7;
  3. Create a JS file;
  4. Try to import { selectorFamily } from "recoil" in this file;
  5. Run npm start and check if error occurs.

Expected behavior

Application should not throw a TypeError.

Actual behavior

TypeError: Object(...) is not a function
Module.<anonymous>
src/recoil/selectors/reportedParkingsQuery.js:20
  17 |   throw error.response.error
  18 | }
  19 | 
> 20 | export const reportedParkingsQuery = selectorFamily({
  21 |   key: "ReportedParkings",
  22 |   get: (carPlate) => async ({ get }) => {
  23 |     const response = await getParkingsByCarPlate(carPlate)

Module../src/recoil/selectors/reportedParkingsQuery.js
http://localhost:8000/commons.js:120193:30
__webpack_require__
/webpack/bootstrap:789

Environment

  • OS: macOS Catalina 10.15.4 (19E287);
  • Node version: v12.16.0;
  • NPM version: 6.13.4;
  • React version: 16.13.1;
  • Recoil version: 0.0.7.

Related code

https://github.com/facebookexperimental/Recoil/blob/1e6e077de77e35dadf28b1a452980f2cb76620a5/src/recoil_values/Recoil_selectorFamily.js#L88-L135

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Cadrachcommented, May 27, 2020

Hi there, thanks for the work on this library!

Is there an easy way to use selectorFamily in recoil currently? I have looked at #33 and #82 but it does not seem to be quite there yet…

1reaction
timeswindcommented, May 26, 2020

Is this the same issue for using atomFamily?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Object(...) is not a function ReactJS + Recoil
When exporting an atom and importing it into App.js, I get a TypeError: Object (...) is not a function, what is the problem?...
Read more >
selectorFamily(options) - Recoil
Returns a function that returns a read-only RecoilValueReadOnly or writeable RecoilState selector.
Read more >
Lessons learned from moving to Recoil.js - Kitemaker blog
If a selector returns an object or an array, Recoil re-renders if the returned value is not referentially equal (i.e. === ) to...
Read more >
Uncaught TypeError | Is Not A Function | Solution - YouTube
Have you encountered an error like:- Uncaught TypeError - Some selector is not a function - jQuery is not a function - owlCarousel...
Read more >
React Hooks Create Failure: Type Error Object () Ist Not A ...
import React, { useState, useEffect } from 'react'; function FriendStatus(props) { const benefits of using React local state, or might not want to...
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