npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-slim

v1.1.0

Published

An attempt to make a minimal react/redux library

Downloads

5

Readme

React-slim

Super small react-redux implementation (~150 lines)

I like to think of it as the unshitification of react :)

The main motivation to write this library was the shock and horror I felt when I noticed that the react library actually has a compiler and rust code that compiles to WASM etc. making me wonder why such a complex implementation was needed for such a simple design pattern.

What you get with this library

  • Simple, understandable code that provides all of the core advantages of using the react design pattern
    • Component updation on declared state changes
    • Action dispatches which trigger state changes, which in turn trigger component updates
  • HTML tag names that correspond to your components, making the structure easy to read and debug
  • Component heirarchies that update efficiently without duplication and unnecessary re-renders
  • action chaining to reduce re-renders and control the order of async actions when needed
  • State need not be immutable
  • Modular structure that allows you to break up your app into multiple sub-apps
  • Flexible, de-coupled implementation that allows you to combine things the way you want to
  • Great performance

What you don't get with this library

  • Magic - no hidden functionality, no side-effects => no surprises or unpredictable behavior
  • Bells and whistles - only one way to work with the library => no confusions
  • developer "protection" - no parameter checking or safety checks => fast, tiny codebase

Understanding react-slim

The following diagram describes how react-slim is organized

React-slim architecture

An example usage of react-slim to create a simple app that demonstrates how to use react-slim is included in the repository, you can see it here

Example application

Opinionated/polarizing design choices

Here are some polarizing design choices I've made in the library. These are points you should seriously consider before adopting react-slim for large applications.

State change propagations are declarative, you'll need to declare state properties that your components depend on, and the properties that your actions modify. This was intentionally done to make it easier to understand component and action dependencies when reading your code, however it does introduce the complexity of manually updating these props when you modify actions or components.

ChatGPT pointed out to me that state propagation across volumes is a disadvantage and suggested centralized state management as an option. I decided to go against its suggestion because multiple volume state changes can easily be triggered by two or more actions on two or more different volumes. React-slim makes a trade-off on centralized state management and shoots for modular state because centralized state management involves complexities in desiging the state for large applications.

ChatGPT also pointed out that I don't use a virtual DOM for efficient updates to the UI, but on researching this topic, again, I found it unnecessary since react-slim only evaluates components whose state has changed, unlike React which evaluates the entire DOM tree on every state update.

How this library will evolve

I don't plan to change the functionality of the library at all. I think the world has too many libraries that change too fast, leaving developers always confused about the right way to build apps or features.

I am, however, open to performance improvements and bug-fixes

Using ChatGPT to generate react-slim apps

The cool thing about react-slim is that 150 lines of code can easily be sent to ChatGPT in a prompt to create react-slim modules and app.

You can use the text of the following file as a prompt to chatgpt. The instructions to ChatGPT are at the end of the file.

ChatGPT Prompt

Far from perfect though, so make sure you match the coding convensions followed in the example application above and edit ChatGPT's output for best results.

Author

Mahadevan K - [email protected]