Skip to content

A repository for my dev.to article about recreating React in vanilla JavaScript in order to achive a similar worflow.

Notifications You must be signed in to change notification settings

maturc/notReact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

notReact

The code in this repository is for my dev.to article about recreating React in vanilla JavaScript in order to achive a similar worflow.

The file notReact.ts contains all of the rendering and state handeling logic, everything else is just an example of a simple counter application.

The finished counter component looks like this:

import * as elements from 'typed-html';
import { notReact } from '../notReact';

const Counter = () => {
  const [count, setCount] = notReact.useState(0);
  
  const increaseCounter = () => {
    setCount(count+1);
  }
  notReact.addOnClick("increaseCount", increaseCounter);
  
  let isHigherThan10: string;
  notReact.useEffect(()=>{
    isHigherThan10 =  count > 5 ? "Yes" : "No";
  }, [count, isHigherThan10]);
  return (
    <div>
      <h1>Counter: {count}</h1>
      <button id="increaseCount">Increase count</button>
      <p>Is the count higher than 5? <strong>{isHigherThan10}!</strong></p>
    </div>
  );
}

export default Counter;

About

A repository for my dev.to article about recreating React in vanilla JavaScript in order to achive a similar worflow.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published