Critique of Pure Hooks

This page summarizes the projects mentioned and recommended in the original post on /r/programming

SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
surveyjs.io
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
  • testing-library-docs

    docs site for @testing-library/*

  • However, I do have a lot of critique of your critique. - Similarity to AngularJS: Yeah, the code looks similar. But it's like saying JS and Java are similar because they look similar. You ignore a lot of pain points that AngularJS had with rerendering, state, side-effects, etc. - It seems to me that you want to write tests in a very "OOP" like manner. If you write tests with something like testing-library, the internal state of the component doesn't really matter, if the output (e.g. the DOM) of the component is as you'd expect it - using hooks and mocking only non-pure external calls should allow you to treat your component as a pure function - even with hooks. - It's much closer to the idea of a rendering library if you move your business logic to a hook instead of having it in your components. Hooks are just functions, and you can render them without having to write a component (again, with testing-library) - so you can test that behavior too, making it very easy to reason about. You really don't need any DI here. I feel like if you need DI in React, you are testing the wrong things and/or are writing weird components. - Hooks don't contradict using Redux. In fact, using Redux is a loooooooot easier with hooks like useSelector. - Not sure why you think going back to OOP patterns would make anything simpler than using hooks. The React Class API is very similar to Vue, and certain parts of Angular, and frankly I think it's a mess. - Never have I ever needed to pass dependencies to a hook. If you do that, you should probably redesign your hooks and/or how they are called.

  • todomvc

    Helping you select an MV* framework - Todo apps for React.js, Ember.js, Angular, and many more

  • With regards to separating business logic and rendering: by far the easiest way to do this is to use the Flux architecture, of which Redux is an example. However, you can also use React as the view layer of MVC frameworks like Backbone, as in this example. I wouldn't really recommend this though.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • react-native-test-sandbox

    Sandbox environment for testing strategies with React Native

  • Here's a contrived example of a test on a list component. And here is the test harness. Even though this example is about components, all of these techniques are applicable to the renderHook api from react-testing-library as well. The test harness wraps the component under test with a react-query store provider, and ui library provider, and a navigation provider. It also provides a means to pass through your own ad hoc wrapper as an argument in the render api if there is some one-off context provider or something else you need for a particular component/hook so it has the dependencies it needs. Once these test harnesses are set up, getting new components/hooks under test is pretty trivial. But thought does need to go into how you design the argument signature of the test harness so you can expressively set it into some prerequisite state before running a test. An example of this is if you want redux to already have something in its store before a test runs.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Why I rarely use `getByRole`: Testing Library and the first rule of ARIA

    1 project | dev.to | 3 May 2024
  • Testing Intercepting Routes

    1 project | /r/nextjs | 11 Nov 2023
  • Mastering Jest: A Complete Guide to Testing Next.js Applications Part-2

    1 project | dev.to | 5 Sep 2023
  • How to run visual tests in 2023

    1 project | dev.to | 25 Aug 2023
  • findByText for Vue Test Utils

    2 projects | dev.to | 10 Jun 2023