Skip to content

Found a flaw calling the same endpoint from multiple locations. #15

@Bram-Zijp

Description

@Bram-Zijp

I was trying to find a solution to a problem and noticed this module has the same flaw. Basically when you have two components that require the same API endpoint, it will fetch the data from that API endpoint twice.

I solved this by adding the fetch promise to the context provider by calling a function that sets it on the this scope in the provider from the hook. You could also use a useRef. Then in the hook I call a getData function that will return undefined/the fetch promise/the data from the context provider.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions