Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solid adapter #25

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Conversation

nivekithan
Copy link
Contributor

@nivekithan nivekithan commented Jan 1, 2023

This pr adds support for solid.js adapter for @remix_run/router package with all tests passing.

In some cases there are differences between react-router and vue implementation, for example Link component in vue does not support relative-path but Link in react does. I have implemented similar to vue only (i.e solid Link also does not support relative-path ). Let me know If i need change that too.

Let me know if anything more needs to be done

@nivekithan nivekithan closed this Jan 1, 2023
@nivekithan nivekithan reopened this Jan 1, 2023
@brophdawg11
Copy link
Owner

This is awesome - thank you for working on this!! I will try to take a look at this in the coming week or so as I get back into the swing of things post-holiday 👍

@nivekithan
Copy link
Contributor Author

Great to hear that, hope you had fun on your holidays.

You can go through the pr in your suitable time.

Anyways, I think I could make few more improvements to pr, mostly combining all files in components folder to one file and others.

I will make those changes after your feedback

@brophdawg11
Copy link
Owner

This looks great! The app looks right to me - I haven't written any SolidJS before so I can't speak much to the specifics but overall the approach and touchpoints with the @remix-run/router look solid to me (pun very much intended 😂 ).

I have implemented similar to vue only (i.e solid Link also does not support relative-path)

Yeah I would ignore relative routing and any basename stuff for now. We're hopefully moving all that logic into the @remix-run/router at some point (see remix-run/react-router#9588), so once we do that Vue/Svelte/Solid can all just inherit it automatically.

I'll go through and leave any comments, but generally I'd say feel free to go through and do any cleanup you'd like. Once that's done we can get it merged to main. Then I'm not sure what's involved in bundling/packaing up a SolidJS npm package - so I'll let you handle that part as well if that's cool with you?

@@ -0,0 +1,34 @@
## Usage
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update this with something like what Vue/Svelte has that shows an example of how to use this in a new Solid app

@@ -8,7 +8,7 @@ export interface TaskItemProps {

export default function TaskItem({ task }: TaskItemProps) {
let fetcher = useFetcher();
let isDeleting = fetcher.formData != null;
let isDeleting = fetcher.formData != null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think changes to this file are unintended :)

Comment on lines +18 to +19
"typescript": "^4.9.4",
"vite": "^4.0.3",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, do we need these updated versions for Solid? Or would the versions installed in the repo root package.json suffice? If these are required for Solid then no worries and eventually I'll get the root versions updated and we can drop these from the dependencies.

"vite-plugin-solid": "^2.5.0"
},
"dependencies": {
"@remix-run/router": "0.2.0-pre.10",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been released as stable since the repo was created. I wouldn't touch anything in this initial PR - but maybe in a follow up we can get it onto the latest (1.2.1, soon to be 1.3.0)

@@ -0,0 +1,69 @@
import type { Component } from "solid-js";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo in the folder name her - reference-app

Comment on lines +63 to +65
const fetcher1 = router.getFetcher("1");
const fetcher2 = router.getFetcher("2");

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused?

Comment on lines +61 to +63
export const useLoaderData = <Data>(): Accessor<Data> => {
return useRouteLoaderData(useRoute().id) as Accessor<Data>;
};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These generics might be slightly misleading. If you return a JSON Response from your loader it'll actually automatically extract the body via res.json() so I think the types might get wrong there.

// The return value here is Response
function loader(): Response {
  return json({ message: 'hello' });
}

// I think this will be typed as Accessor<Promise<Response>> 
// but it's actually of type { message: string }
const data = useLoaderData<ReturnType<typeof loader>>();

We left them out of the initial versions of these in react-router to make sure we eventually got them right, so I might suggest the same in the Solid version.

@nivekithan
Copy link
Contributor Author

Thanks for the feedback. I will work on those over the week and update the pr

@nivekithan
Copy link
Contributor Author

Sorry, I got busy with some other work. I will try to finish this by week

@brophdawg11
Copy link
Owner

No rush at all!

@znycheporuk
Copy link

Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants