0.1.5 • Published 6 years ago
@saber2pr/tsx v0.1.5
@saber2pr/tsx
a tsx renderer for the browser and node.js
纯粹的视图层
# from npm
npm install @saber2pr/tsx
# from github
git clone https://github.com/Saber2pr/tsx.gitExamples
in browser.
import TSX, { renderDOM } from '@saber2pr/tsx'
function HelloMessage({ name }) {
  return <div>Hello {name}</div>
}
// render to dom.
document
  .getElementById('root')
  .append(renderDOM(<HelloMessage name="Taylor" />))in node.js
import TSX, { renderString, Style } from '@saber2pr/tsx'
function Page({ name }) {
  return (
    <html>
      <head>
        <Style>
          {{
            '.myTsx': { color: 'blue' }
          }}
        </Style>
        <title>{name}</title>
      </head>
      <body>
        <div className="myTsx">myTsx</div>
      </body>
    </html>
  )
}
// render to string.
console.log(renderString(<Page name="My Tsx" />))tsx
- tsx map
 - tsx render children
 
and more feature supported.
tsconfig
ensure:
{
  "compilerOptions": {
    "jsx": "react",
    "jsxFactory": "TSX"
  }
}start
npm installnpm start
npm run devAuthor: saber2pr
develope and test
you should write ts in /src
you should make test in /src/test
export your core in /src/index.ts!