Giter Club home page Giter Club logo

react-chaos's Issues

Chaotic Interaction

Love that youโ€™ve taken up this effort!

What are your views on a Chaos actor that performs random interaction with the UI? Eg clicking buttons, entering text in inputs etc.

While this does not really simulate typical user interaction, perhaps it can highlight issues around what should be interactive at any given time (contrived example is to disable a button that triggers some async action)?

Think through public API for Chaos component

This is a first pass at what the API for Chaos could look like. Suggestions welcome!

<Chaos
  level={5}
  message="a custom error message"
  shallow
  depth={3}
  statelessOnly
  statefulOnly
  monkeys
  disasters={[
    "network",
    "language",
    "time",
    "location",
    "machine"
  ]}
>
  <SomeComponent />
  <AnotherComponent />
</Chaos>

level

This is a number (1-10) that allows you to set the likelihood of chaos occurring.

message

This is a custom error message you can pass in that will be displayed as the message when an error is triggered.

shallow & depth (Children & Nested Components)

Ideally, one should be able to wrap a single component, a component with children, or a component with grandchildren (possibly even their entire application), with Chaos.

It could have a depth prop that allows you to explicitly set the number of grandchildren to apply chaos to. It could also recursively apply chaos to all grandchildren unless you pass in a shallow prop, in which case chaos would only be applied to the immediate children.

statelessOnly & statefulOnly

These props would allow you to only apply potential chaos to stateless components or stateful components.

monkeys

This will be a special surprise. ๐Ÿ’

disasters

This will allow you to specify the types of chaos that could occur. I think there will be a lot of new types in the future, but off the top of my head I thought about those listed. I think there's also potential for React-specific types of chaos, such as causing random re-renders and such, but only insofar that it mimics chaos that could actually occur in the real world.

React hooks

Looks like a really nice project!

I think having a useChaos hook can be really useful and will also won't encapsulate the wrapped component

the newest npm package wrong?

Hi,

I try to install the the newest react-chaos(version 0.1.0?) and have a try.
I found that you may don't publish release files to npm.

Best.

Module not found: Error: Can't resolve './chaos-react.cjs.development.js' in '/home/xxxxx/chaos-demo/node_modules/react-chaos/dist

Hi, I am experiencing this error when I use the package.

Compiled with problems:
ร—
ERROR
Cannot find module './chaos-react.cjs.development.js'
    at webpackMissingModule (http://localhost:3000/static/js/bundle.js:7050:69)
    at ./node_modules/react-chaos/dist/index.js (http://localhost:3000/static/js/bundle.js:7050:176)
    at options.factory (http://localhost:3000/static/js/bundle.js:41417:31)
    at __webpack_require__ (http://localhost:3000/static/js/bundle.js:40840:33)
    at fn (http://localhost:3000/static/js/bundle.js:41074:21)
    at ./src/App.js (http://localhost:3000/static/js/bundle.js:17:69)
    at options.factory (http://localhost:3000/static/js/bundle.js:41417:31)
    at __webpack_require__ (http://localhost:3000/static/js/bundle.js:40840:33)
    at fn (http://localhost:3000/static/js/bundle.js:41074:21)
    at ./src/index.js (http://localhost:3000/static/js/bundle.js:119:62)
ERROR in ./node_modules/react-chaos/dist/index.js 6:2-62
Module not found: Error: Can't resolve './chaos-react.cjs.development.js' in '/home/xxxxx/chaos-demo/node_modules/react-chaos/dist'

What I tried

  • Deleting package-lock.json and running npm install
  • Verified that the module 'react-chaos' is installed in my project by running npm list react-chaos

my code

import React from 'react';
import withChaos from 'react-chaos';

// Define a component
const ComponentToWrap = () => {
  // Simulate an error
  if (Math.random() < 0.5) {
    throw new Error('Oops! Something went wrong.');
  }

  return <p>I may have chaos.</p>;
};

// Wrap the component with Chaos
const ComponentWithChaos = withChaos(ComponentToWrap, 8, 'Custom error message: Chaos level 8');

// Create a component with Chaos level 8 and a custom error message
const App = () => {
  return (
    <div>
      <h1>React Chaos Demo</h1>
      <ComponentWithChaos />
    </div>
  );
};

export default App;

Nothing is exported?

Looking into /dist in the npm packaged bundle - there's nothing in the index.js?

         'use strict'

      if (process.env.NODE_ENV === 'production') {
        module.exports = require('./chaos-react.cjs.production.js')
      } else {
        module.exports = require('./chaos-react.cjs.development.js')
      }

runtime error of this package

error - ./node_modules/react-chaos/dist/index.js:7:0
Module not found: Can't resolve './chaos-react.cjs.development.js'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.