As a developer
I want to use the selectorFamily helper function
So that I can make asynchronous queries with parameters
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.
Maybe exporting the selectorFamily helper at the recoil library.
npm install recoil --save-exact to install version 0.0.7;import { selectorFamily } from "recoil" in this file;npm start and check if error occurs.Application should not throw a TypeError.
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
selectorFamily isn't currently exported in published version on npm. Though, the code is there so you can explore using it directly. #33 should help fix the exporting issue for the open-source version.
Note that we want to keep the core API simple. So, optional helpers built on top of the core API are being exported in a RecoilUtils module.
@drarmstr thank you.
Since, for now, the code is not exported nicely with the build, does it make sense to put that information at selectorFamily at docs, and update it as #33 is fixed?
@jimmyandrade The code is available here, it's just not being exported nicely with the build. Thanks for bearing with us as we're getting the initial release of this beta library up and going.
Thank you for the support.
And, sorry, I didn't express myself well in the last comment. I've found the helper function code:
Hey @jimmyandrade, sorry about that mis-match. We are pretty new at this. Anyway, selectorFamily is (for now) just a simple memoized function, although we will probably add some other tricks for memory management soonish. Hope that unblocked you for now?
Hey @davidmccabe! Don't worry, the work you people are doing is already helping a lot.
In fact, I still haven't been able to unlock what I need. I'm talking about it here: #178
@jimmyandrade Hey bro, do you already resolved this?
Is this the same issue for using atomFamily?
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...
@timeswind - Yes, same issue for atomFamily or any of the other utils
@Cadrach - Can you fork the repository instead of using the NPM package as a workaround for now? We're getting close, though..