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.

first time with recoil any tip for access params

See original GitHub issue

TypeError: Object(…) is not a function

i get this error when am trying send params down

export const fetchjobs = selector({ key: “fetchjobs”, get: (counter) => async ({ get }) => { try { const response = axios( "/jobs? _start= + counter + “&_limit=10” ); const data = response.data; return data; } catch (error) { console.log(error); throw error; } }, });

i call it

const jobsDataFetched = useRecoilValueLoadable(waitForAll(fetchjobs(20)));

if (state === “hasValue”) { const { contents } = jobsDataFetched; // console.log(contents); return <JobsLayout postlist={contents} />; }

what ever every thing works just fine if i called it with out any parameters

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
acutmorecommented, Jun 1, 2020

Hi @hazem-a1

If you want to pass a parameter to a selector then you might be looking for selectorFamily.

export const fetchjobs = selectorFamily({
  key: "fetchjobs",
  get: (counter) => async ({ get }) => {
    try {
      const response = await axios(`/jobs? _start=${counter}&_limit=10`);
      const data = response.data;
      return data;
    } catch (error) {
      console.log(error);
      throw error;
    }
  },
});

...

const jobsDataFetched = useRecoilValueLoadable(fetchjobs(20)); // waitForAll not needed
1reaction
hazem-a1commented, Jun 1, 2020

ok after changed the mock data api it works fine i can access the data from my component

i must done some thing wrong in my app i just will refactor it

thanks for help @acutmore

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exploring Asynchronous Requests in Recoil - AppSignal Blog
Recoil makes it possible to fire requests as soon as an event like a click occurs. The query does not execute in the...
Read more >
reactjs - Recoil Atom and Typescript, define type and pass ...
At this time, I use the default property to define each ... I want to pass an atom in a function but I...
Read more >
Recoil - Counter-Strike Wiki - Fandom
Due to how the recoil application stays constant, spray patterns, the pattern that bullets make while spraying due to recoil but without any...
Read more >
NGSW: Pros and cons of the Next Generation Squad Weapon ...
Both weapons utilize a gas and recoil system, but General Dynamics has not elaborated any further. A short recoil, impulse averaging ...
Read more >
External ballistics (from gun to target) - FIREARMS TUTORIAL
Higher pressures require a bigger gun with more recoil that is slower to load and ... As the bullet traverses the barrel of...
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