All Projects → tvler → Experimental React Like Framework

tvler / Experimental React Like Framework

Licence: mit
A new, experimental frontend for React inspired by SwiftUI. In development.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
dsl
153 projects

Projects that are alternatives of or similar to Experimental React Like Framework

Front End Web Development Resources
This repository contains content which will be helpful in your journey as a front-end Web Developer
Stars: ✭ 3,452 (+1090.34%)
Mutual labels:  frontend, front-end
Mini.css
A minimal, responsive, style-agnostic CSS framework!
Stars: ✭ 2,938 (+913.1%)
Mutual labels:  frontend, front-end
Learningrecord
学习资料汇总、阅读记录,持续学习,每天进步一点点.🏫🏫
Stars: ✭ 95 (-67.24%)
Mutual labels:  frontend, front-end
Medlaunch
A Windows (.NET) Front-End for the Mednafen Emulator
Stars: ✭ 37 (-87.24%)
Mutual labels:  frontend, front-end
Saltgui
A web interface for managing SaltStack based infrastructure.
Stars: ✭ 278 (-4.14%)
Mutual labels:  frontend, front-end
Dev Practice
Practice your skills with these ideas.
Stars: ✭ 1,127 (+288.62%)
Mutual labels:  frontend, front-end
Fast
Develop, build, deploy, redeploy, and teardown frontend projects fast.
Stars: ✭ 126 (-56.55%)
Mutual labels:  frontend, front-end
Computer Science
Contains the basic fundamental data structures and algorithms a front end engineer should know, written all in JavaScript.
Stars: ✭ 798 (+175.17%)
Mutual labels:  frontend, front-end
Kunafa
Easy to use, high level framework in Kotlin for front-end web-development
Stars: ✭ 148 (-48.97%)
Mutual labels:  frontend, front-end
Roadmap Web Developer 2017
Front-end (HTML5/CSS3/Javascript related) technologies to learn in 2017
Stars: ✭ 142 (-51.03%)
Mutual labels:  frontend, front-end
Astral
⊙ CSS franken-work ⊙
Stars: ✭ 14 (-95.17%)
Mutual labels:  frontend, front-end
Frontend Developer Roadmap
📘 Front-end developer roadmap in 2021. This repository aims to collect the most important concepts of front-end.
Stars: ✭ 233 (-19.66%)
Mutual labels:  frontend, front-end
Itelios Frontend Challenge
Desafio de admissão para desenvolvedores front-end da Itelios
Stars: ✭ 14 (-95.17%)
Mutual labels:  frontend, front-end
Web Interview
我是「齐丶先丶森」,公众号「前端面试秘籍」作者,收集整理全网面试题及面试技巧,旨在帮助前端工程师们找到一份好工作!
Stars: ✭ 1,230 (+324.14%)
Mutual labels:  frontend, front-end
Livingstyleguide
Easily create front-end style guides with Markdown and Sass/SCSS.
Stars: ✭ 874 (+201.38%)
Mutual labels:  frontend, front-end
Rxios
A RxJS wrapper for axios
Stars: ✭ 119 (-58.97%)
Mutual labels:  frontend, front-end
Front End Career
A career guide to Front End Developers
Stars: ✭ 765 (+163.79%)
Mutual labels:  frontend, front-end
Snapchat Clone
👻 A SnapChat clone built with React, Redux and Typescript. Styled with SASS. Tested with Cypress, Jest and Enzyme. Linted with Eslint and formatted with Prettier!
Stars: ✭ 770 (+165.52%)
Mutual labels:  frontend, front-end
Fe Interview
😃 每日一道经典前端面试题,一起共同成长。
Stars: ✭ 134 (-53.79%)
Mutual labels:  frontend, front-end
Bit
A tool for component-driven application development.
Stars: ✭ 14,443 (+4880.34%)
Mutual labels:  frontend, front-end

experimental-react-like-framework

A new, experimental frontend for React inspired by SwiftUI. In development.

Based off of two questions:

① What would React look like if execution-order-based code wasn't used only for hooks, but for everything?

② What would React look like if JSX never existed?

Hello World app:

const App = () => {
  h1("Hello world!");
};

The framework is hosted on React itself. Designed to be incrementally adopted inside of a React subtree without interfering with any existing code, with the benefit of all of React's features and ecosystem.

import { NewFramework } from "./NewFramework";
import { NewFrameworkApp } from "./NewFrameworkApp";

const App = () => (
  <YourExistingReactApp>
    <YourExistingReactComponent />

    {/* 🆕 */}
    <NewFramework root={NewFrameworkApp} />
  </YourReactApp>
);

Table of contents

Framework write-up

Bet: JSX is bad

JSX immediately requires a complex build environment. Differences between HTML is small but painful for beginners. Sebastian Markbåge (a lead react maintainer) tweeted that JSX is a bug.

(twitter.com/sebmarkbage/status/1255886278437945344)

Bet: React.createElement is bad

Using React without JSX forces you to use the React.createElement API. Building a complex template with React.createElement ends up as a deeply-nested function call with no breakpoints at the very bottom of your component code. JSX is an attempt to make this format more presentable, but it doesn't solve the underlying issue that your template is inside of a function call, with no access to if-statements, for-loops, etc.

Bet: Code based off of execution-order is good

Facebook built hooks around execution-order and received major backlash by the engineering community, but resulted in few actual real-world problems.

Result

An exploration of what react would look like if execution-order-based code wasn’t considered an antipattern, and if JSX never existed.

/*
 * New syntax
 */
const App = () => {
  const [counter, setCounter] = useState(0);
  const handleClick = () => {
    setCounter(counter + 1);
  };

  h1("Hello world!");

  // A button with an onClick prop
  button({ onClick: handleClick }, counter);

  // An ordered list counting up from 0 to 9
  ol(() => {
    for (let i = 0; i < 10; i++) {
      li({ key: i }, i);
    }
  });

  // Conditionally rendering a span if counter is odd
  if (counter % 2) {
    span("counter is an odd number.");
  }
};

/*
 * Old JSX syntax
 */
const JSXApp = () => {
  const [counter, setCounter] = useState(0);
  const handleClick = () => {
    setCounter(counter + 1);
  };

  return (
    <>
      <h1>Hello world!</h1>

      {/* A button with an onClick prop */}
      <button onClick={handleClick}>{counter}</button>

      {/* An ordered list counting up from 0 to 9 */}
      <ol>
        {Array.from({ length: 10 }, (_, i) => (
          <li key={i}>{i}</li>
        ))}
      </ol>

      {/* Conditionally rendering a span if counter is odd */}
      {counter % 2 && <span>counter is an odd number.</span>}
    </>
  );
};

Benefits

Simpler code for loops and conditional rendering

Zero distinction between functions and components

Don’t have to learn JSX

No return statement

No need for closing tags

No need for fragments

Easier to comment elements out

How it works

Each primitive HTML element function pings a global store when called. The order of the pings determines the order in which the actual HTML elements are rendered to the dom. This is the exact same architecture that Facebook has proven successful with react hooks.

This has the potential to work directly within React itself, turning into a series of React.createElement calls on execution. Making this an experimental new frontend for React, with the added benefits of gradual adoption and an already-existing suite of developer tools to build off of.

What I've built so far

✅ Working prototype

cd example-create-react-app
yarn
yarn start

✅ Everything except state

example-create-react-app/src/app.ts

import { button, h1, ol, li } from "./Framework";

const app = () => {
  h1("Hello world!");

  // A button with an onClick prop
  button(
    {
      onClick: () => {
        alert("clicked!");
      },
    },
    "Click"
  );

  // An ordered list counting up from 0 to 9
  ol(() => {
    for (let i = 0; i < 10; i++) {
      li(i);
    }
  });
};

export default app;

✅ Building on top of React

example-create-react-app/src/index.ts

import React from "react";
import ReactDOM from "react-dom";
import { Framework } from "./Framework";
import app from "./app";

ReactDOM.render(
  React.createElement(Framework, { root: app }),
  document.getElementById("root")
);

What needs to be built

Further reading

Function builders (draft proposal) by John McCall and Doug Gregor

js-dsl by Venkat Peri

incremental-dom by Google

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].