Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ssssota/svelte-react-snippet

Create svelte snippets with JSX syntax based on react
https://github.com/ssssota/svelte-react-snippet

react svelte

Last synced: 29 days ago
JSON representation

Create svelte snippets with JSX syntax based on react

Awesome Lists containing this project

README

        

# svelte-react-snippet

You can create svelte snippets with JSX syntax based on react.
This means you can use react components in svelte as snippets.

## Usage

```sh
npm i svelte-react-snippet react
```

tsconfig.json

```jsonc
{
"compilerOptions": {
// ...
"jsx": "react-jsx",
"jsxImportSource": "react"
}
}
```

snippet.tsx

```tsx
export const snippet = createSnippet<[string, string]>((title, content) => (



{title()}



{content()}

alert('Clicked!\n' + content())}>Click me


));
```

App.svelte

```svelte

import {page} from '$lib';
let name = $state('react');

{@render page('svelte-react-snippet', `Hello ${name}!`)}

```

→ **[Demo](https://ssssota.github.io/svelte-react-snippet/)**

## License

MIT