remix
remix copied to clipboard
feat(remix-server-runtime): add loader context generic types
Because the context does not change too often, users can easily customize it without having to use the type to correspond to it every time.
for example:
import { LoaderFunction } from 'remix';
type MyContext = {
user: string
}
type LoaderFunctionWithContext = LoaderFunction<MyContext>
export const loader: LoaderFunctionWithContext = () => {}
Hi @rwu823,
Welcome, and thank you for contributing to Remix!
Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.
You may review the CLA and sign it by adding your name to contributors.yml.
Once the CLA is signed, the CLA Signed label will be added to the pull request.
If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected].
Thanks!
- The Remix team
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳
Hi @rwu823 and sorry for the delays. Can you rebase your PR to target the dev branch?
@machour done.
@rwu823 Could you please rebase your branch on latest dev & resolve conflicts?
@MichaelDeBoey done.
Just came across this today and this PR would be nice to have.
My use case is that I would like to use the context for dependency injection w.r.t Actions and Loaders, so it would be nice to type the context and get autocomplete without having to typecast context in each loader.
Just checking in, any way we can get this merged in? This becomes especially helpful now that the meta function is typed off of the loader. Without this change, meta will always consider data to be any if the loader function is typed.
This PR has been automatically closed because we haven't received a response from the original author 🙈. This automation helps keep the issue tracker clean from PRs that are unactionable. Please reach out if you have more information for us! 🙂