Skip to content

orsi/jinx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jinx

a minimalist jsx rendering library

setup

// tsconfig.json
{
  "compilerOptions": {
    "jsx": "preserve"
  }
}
// vite.config.ts
import { defineConfig } from "vite";

export default defineConfig({
  esbuild: {
    jsx: "transform",
    jsxFactory: "__jsx",
    jsxFragment: "__Fragment",
    jsxInject: "import { jsx as __jsx, Fragment as __Fragment } from 'jinx';",
  },
});

about

nothing really here now other than:

  • exports:
    • useState(initialValue)
    • useReducer(reducer, initialState)
    • jsx and Fragment aka <></>
      • you'd most likely setup Vite or Typescript to auto-import these type definitions for working with HTML elements and function components in JSX
  • renders JSX/TSX syntax
  • testing app based off js-framework-benchmark
function MyApp() {
  const [toggle, setToggle] = useState(true);

  const onClick = () => {
    setToggle(!toggle);
  };

  return (
    <>
      <button onClick={onClick}>Switch!</button>
      {toggle ? <div>1</div> : <div style={{ textAlign: "right" }}>2</div>}
      <hr />
      {toggle && <small>up</small>}
      {!toggle && <em>down</em>}
    </>
  );
}

quick dev start

git clone https://github.com/orsi/jinx.git
cd jinx
npm i
npm run dev

About

Barebones reactive JSX with functional components

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published