Coder Social home page Coder Social logo

react-stand-in's Introduction

List of all projects

State

React

Code splitting

Node

Data sources

Vue

DOM

Util

Mocking

Styles

Optimizations

Stuff

Rest

Just articles

Habr articles (russian)

react-stand-in's People

Contributors

thekashey avatar

Watchers

 avatar  avatar  avatar

react-stand-in's Issues

Spike to replace react-proxy

@Neziro - this is mostly for you.
So. What problem we had - in pure ES6/7 environment:

  1. Arrow functions are just not working due to wrong this.
  2. Babel plugin may do something quite wrong.

Solution:
Step 1 - disable babel magic. At all. Keep only the register function.
Step 2 - try to create workaround, to make RHL work again.
Step 3 - modify RHL to fix all the things..

Step 1.
Simple remove half of babel plugin. All related to the "Class" traverse.

Step 2.
Create react-stand-in, based on react-proxy. Also - just remove 90% code, and change the root logic.
As long it is 99% incompatible to the assessor - it is easy to create a separate repo.

How it work.
It creates a single class, by extending the original and never change or fake this in the future.
It just uses JS core feature - prototype chain.
when you want to update a component - you just change your ancestor

Object.setPrototypeOf(ProxyComponent.prototype, NextComponent.prototype);

And this is covering 99% cases for 99% code. Without any real proxy, which just duplicate the core functionality.
All cases except inability to call constructor, and repeat code, might be hidden inside it.

Step 3 - Whats left?

  1. As long arrow functions are moved to the constructor, it is just impossible to regenerate them. But it is possible to detect the change (https://github.com/theKashey/react-stand-in/blob/master/src/createClassProxy.js#L34) and do something.
    Currently - just display an error.
    In Future - patch RHL's babel plugin, to add magic method to a class declaration
  class { 
   ....
 __RHL_MAGIC_INSERT(key,data){ this[key]=eval(data); }  // yep! Eval. Must be in the same scope.
 }

Next - it will be possible to regenerate bound methods.

 const inst = new NextComponent();
 ThisProxyGeneration.injectOnRender( that => that.__RHL_MAGIC_INSERT(arrowMethod,arrowMethod.toString())

Something similar can be done for bound methods - it is possible to detect that method is bound( or via undefined prototype, or one can patch Function.bind :) ), and regenerate them on render.
Unfortunately it requires different approaches, but look like one could deprecate .bind as obsolete.
Actually - the problem is with the new code, not the old.

PS: It is not always easy to understand me. Just for you information.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

`Objects are not valid as a React child` after upgrading from `4.0.0-beta.13`

Error: Objects are not valid as a React child (found: object with keys {props, context, refs, updater, __reactstandin__proxyGeneration, __reactstandin__cachedResult}). If you meant to render a collection of children, use an array instead.null
    at invariant (invariant.js:42)
    at traverseAllChildrenImpl (react.development.js:805)
    at traverseAllChildren (react.development.js:833)
    at Object.countChildren [as count] (react.development.js:945)
    at doTraverse (index.js:84)
    at doVisit (index.js:116)
    at index.js:172
    at new Promise (<anonymous>)
    at reactTreeWalker (index.js:70)
    at mapper (index.js:88)

Reproduction: https://github.com/JounQin/react-ssr/tree/react-stand-in
Branch: react-stand-in

For now, I'm locking [email protected], you can remove resolutions in package.json and run yarn && yarn dev, then visit http://localhost:4000.

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.