Using Suspense within our component isn't exactly ergonomic. Let's put all that logic into a reusable function so we can create resources anytime we need them and for any asynchronous interaction in our app.
I saw this description of the createResource in another video, but your refactoring from a specific pokeman fetch to a generic resource fetch really got the concept across! Thanks KCD
Great stuff, I think for a createResource
function would be better to pass a promise rather than a function, so createResource
won't be obliged with managing the invocation of the passed-in function.
FYI, none of the code samples work anymore because Could not find module in path: 'react/jsx-runtime' relative to '/src/app.js'