Skip to content

Commit

Permalink
Fix loading of React type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
sholladay committed Sep 7, 2020
1 parent f1fc12f commit 64ef113
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -129,10 +129,10 @@ You can do webpage templating with [React](https://reactjs.org/) inside of route

Pogo automatically renders React elements using [`ReactDOMServer.renderToStaticMarkup()`](https://reactjs.org/docs/react-dom-server.html#rendertostaticmarkup) and sends the response as HTML.

Save the code below to a file named `server.jsx` and run it with a command like `deno --allow-net server.jsx`. The `.jsx` extension is important, as it tells Deno to compile the JSX syntax. You can also use TypeScript by using `.tsx` instead of `.jsx`. The type definitions should load automatically from the Pika CDN, but if you run into problems when using `.tsx`, try loading them manually (see [deno_types](https://github.com/Soremwar/deno_types)).
Save the code below to a file named `server.jsx` and run it with a command like `deno --allow-net server.jsx`. The `.jsx` extension is important, as it tells Deno to compile the JSX syntax. You can also use TypeScript by using `.tsx` instead of `.jsx`, in which case you should add an `// @deno-types` comment to load the type definitions for React (see [deno_types](https://github.com/Soremwar/deno_types)).

```tsx
import React from 'https://cdn.pika.dev/react';
import React from 'https://jspm.dev/react';
import pogo from 'https://deno.land/x/pogo/main.ts';

const server = pogo.server({ port : 3000 });
Expand Down
7 changes: 4 additions & 3 deletions dependencies.ts
@@ -1,10 +1,11 @@
import React from 'https://cdn.pika.dev/react@16.13.1';
// @deno-types="https://github.com/soremwar/deno_types/raw/4a5066025e84d2c5353d0f40a8869c65d7c82734/react-dom/v16.13.1/server.d.ts"
// @deno-types="https://raw.githubusercontent.com/soremwar/deno_types/b5a146610e2c97c1612371fcf610b541f950ee73/react/v16.13.1/react.d.ts"
import React from 'https://jspm.dev/react@16.13.1';
// @deno-types="https://raw.githubusercontent.com/soremwar/deno_types/b5a146610e2c97c1612371fcf610b541f950ee73/react-dom/v16.13.1/server.d.ts"
import ReactDOMServer from 'https://jspm.dev/react-dom@16.13.1/server';
import * as cookie from 'https://deno.land/std@v0.64.0/http/cookie.ts';
import * as http from 'https://deno.land/std@v0.64.0/http/server.ts';
import { Status as status, STATUS_TEXT as statusText } from 'https://deno.land/std@v0.64.0/http/http_status.ts';
import * as mime from 'https://cdn.pika.dev/mime-types@2.1.27';
import * as mime from 'https://jspm.dev/mime-types@2.1.27';
import * as path from 'https://deno.land/std@v0.64.0/path/mod.ts';

export {
Expand Down
2 changes: 1 addition & 1 deletion example/react-on-server/dependencies.ts
@@ -1,5 +1,5 @@
import pogo from 'https://deno.land/x/pogo/main.ts';
import React from 'https://cdn.pika.dev/react@16.13.1';
import React from 'https://jspm.dev/react@16.13.1';

export {
pogo,
Expand Down

0 comments on commit 64ef113

Please sign in to comment.