Giter Club home page Giter Club logo

fusion-plugin-react-router's Introduction

Modern framework for fast, powerful React apps

Build status fusion-core Downloads

What is it?

fu·sionnoun

The process or result of joining two or more things together to form a single entity.

Fusion.js, Uber’s open source universal web framework, represents the fusion of the client and the server. It's geared for server-side rendering out of the box, and its plugin-driven architecture allows for complex frontend and backend logic to be encapsulated in a single plugin:

import App from 'fusion-react';
import Router from 'fusion-plugin-react-router';

export default () => {
  const app = new App(<div>...</div>);

  /*
  One line of code sets up everything you need for routing:
  - Server rendering
  - React Providers on both server and browser
  - Bundle splitting integration
  - Hot module reloading support
  */
  app.register(Router);

  return app;
}

We initially built Fusion.js to make our own websites easier to maintain, but were so impressed with the benefits that we decided to offer it to the community as an open source project!

Try it out

If you're interested in giving Fusion.js a shot, Overview and Core Concepts are great places to start.

Contributing

This is a monorepo of all open source Fusion.js packages maintained using Yarn v2. Take a look at CONTRIBUTING.md for info on how to develop in this repo.

License

MIT

fusion-plugin-react-router's People

Contributors

albertywu avatar alexmsmithca avatar brendean avatar chrisdothtml avatar conradreuter avatar dennisgl avatar ganemone avatar kevingrandon avatar lhorie avatar nadiia avatar rajeshsegu avatar renovate-bot avatar renovate[bot] avatar rtsao avatar sumanvyj avatar uberopensourcebot avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fusion-plugin-react-router's Issues

Support server-side route redirects to external url

Type of issue

Feature request

Description

There seems to be no way to set up redirects (302s) to external urls. I understand this might be to keep consistent behavior with react-router v4's browser redirect behavior. Perhaps we can offer an <ExternalRedirect> component in fusion-plugin-react-router to workaround this?
Alternatively, if there's some way of doing this otherwise, please document it.

Current behavior

Right now, in order to set up an external redirect route, I'm doing this. This method is clearly sub-optimal since the browser is loading the page with a null component just to redirect (and there's no way to leverage 302 status code here):

    <Route
      path={`/go-to-google`}
      render={() => {
        if (__BROWSER__) {
          window.location.href = 'https://www.google.com';
        }
        return null;
      }}
    />

Expected behavior

Support a syntax like:

    <Route
      path={`/go-to-google`}
      render={() => <Redirect to={"https://www.google.com"} />}
    />

Fix routePrefix behavior now that we are stripping the routePrefix on the server side

Type of issue

Bug

Description

When fusion-core was updated to strip the routePrefix from ctx, the router plugin was never updated to handle this behavior.

Current behavior

Links and route matching don't work as expected.

Expected behavior

Links and route matching should work with the routePrefix.

Steps to reproduce

  1. run a Fusion.js application with the ROUTE_PREFIX environment variable set
  2. add some <Route> components and <Link> components

Add Token dependencies to readme

Problem/Rationale

Documentation regarding Fusion API is out of date given recent changes to leverage new Dependency Injection architecture.

Solution/Change/Deliverable

Update documentation

Handle non object event payloads

In theory users could emit events with primitive values
for the event payload. We should only try and extend the
payload if it is a truthy object.

Status component only renders first child

Type of issue

Bug

Description

When rendering the Status component on the server if multiple children are passed in only the first is rendered.

Current behavior

Only first child is rendered

Expected behavior

All children should render

Your environment

  • fusion-plugin-react-router version: 1.5.3-alpha.0

Redirect component doesn't work in browser

Type of issue

Bug

Description

On the browser the Redirect component will cause an exception

Current behavior

Exception is thrown

Expected behavior

Should work on browser and server

Steps to reproduce

  1. Render Redirect component in the browser
  2. See the error: 'checkPropTypes.js:19 Warning: Failed context type: The context router is marked as required in Redirect, but its value is undefined.'

Your environment

  • fusion-plugin-react-router version: 1.5.0-1

Use scoped emitter for page view stats

Type of issue

Feature request

Description

Instead of using the globally scoped event emitter using an emitter scoped to the request should allow us to log events with context specific details (actual path and headers from the request). This would also require the context object being passed into the emit call.

Current behavior

pageview:server is emitted on the global event bus and does not include context.

Expected behavior

pageview:server is emitted on a event bus scoped to an individual request and includes the context.

Fix server side redirects

Server side redirects are setting the status
code correctly, but are not adding the Location
header. We should use ctx.redirect

MemoryRouter does not provide onRoute context

Type of issue

Bug

Description

MemoryRouter does not provide onRoute into child context
Besides it would be nice to be able to override onRoute with some mock function

Current behavior

When using MemoryRouter for UnitTesting it fails with following error:
TypeError: context.onRoute is not a function

Expected behavior

Should not fails on this step

Steps to reproduce

run following test snippet:

    const component = mount(
      <MemoryRouter initialEntries={['/test']}>
        <Route path="/test" render={() => <div>Test</div>} />
      </MemoryRouter>
    );

    expect(component.find('div').text()).toBe('Test');

Your environment

  • fusion-plugin-react-router version: 1.2.0

  • Node.js version (node --version): 8.14

  • npm version (npm --version): 6.4.1

  • Operating System: OSX

Unable to style Link components with styletron

I'm having trouble styling Link components. If you nest an anchor element or anchor component, Fusion will create another anchor instead of rendering one anchor. If you pass the Link component into styletron's withStyle, Fusion crashes.

Is there a way to style Links with styletron? I'd prefer to avoid using inline style and nesting a random element for the purposes of styling.

Unable to use `render` prop for `Route`

Type of issue

Feature request

Description

The render prop is the suggested approach for passing props to a Route from a parent component but fusion-plugin-react-router does not allow this property.

Current behavior

When passing the prop render to the Route component an error is thrown 'Cannot pass render function to tracking route'.

Expected behavior

Should be able to pass render to a Route

Your environment

  • fusion-plugin-react-router version: 1.0.4

Only emit render and pageview events

The upstream and downstream timing events should probably be handled
by some standard stats library, not the router. It does make sense for
the router to emit render/pageview stats, but not more generic stats like
upstream and downstream.

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.