Git Product home page Git Product logo

react-native-portal's People

Contributors

bailycase99 avatar dependabot[bot] avatar doomsower avatar zenyr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-portal's Issues

Emit when BlackPortal unmounts

Current behaviour

  • I unmount BlackPortal, but it's children are displayed in WhitePortal after this event.

Expected behaviour

  • I unmount BlackPortal, it's children should be "removed" from WhitePortal

From code, I see BlackPortal does not emit on unmount. Would this solve the issue?

Deprecated status

Just curious why the repo is deprecated. Are there any alternatives out there?

react-native throws 'maximum update depth exceeded exception' when you use BlackPortal

image

export default class App extends Component {
    render() {
        return (
            <View style={styles.container}>
                <BlackPortal name="simple">
                    <Text>Welcome to React Native!!!</Text>
                </BlackPortal>
                <Text>Welcome to React Native!</Text>
                <WhitePortal name="simple" />
            </View>
        );
    }
}
package.json
"react": "^16.2.0",
"react-native": "^0.52.0",
"react-native-portal": "^1.2.1"

ios InputText not english input bug

My React Native version is 0.33
and it seems this bug was fixed in 0.54, but i have not checked.
facebook/react-native#18403

Here is My Component

<Comp>
      <BlackPortal name="wow">
        <TextInput
          style={{ backgroundColor: 'gray', borderWidth: 2, borderColor: 'blue', height: 80, flex: 1 }}
          onChangeText={this.onChangeText}
          value={this.state.value}
        />
      </BlackPortal>
</Comp>

and AppRoot

<AppRoot>
   <Comp />
   <WhitePortal name="wow"></WhitePortal>
</AppRoot>

and there is a bug in not-english Keyboards, while mine is Chinese (Simplified) -Pinyin
look at
2018-06-04 23 38 02

and i also try Korean
2018-06-04 23 37 32

the same bug, only in English , it can be worked well
2018-06-04 23 38 23

Actually, i found this bug, because i have written an Portal very likely with your's, here is an simply
code

import { View } from 'react-native';
import React, { Component } from 'react';
import mitt from 'mitt';

let uuid = 0;
const mitter = mitt();


const sendPortal = (uuidReactChildren) => {
  mitter.emit('portal_on_change', uuidReactChildren);
};

const rmPortal = (uuid) => {
  mitter.emit('portal_rm', uuid);
};



export default class Portal extends Component {
  constructor(props) {
    super(props);
    this.uuid = uuid++;
  }
  componentDidMount() {
    sendPortal({ children: this.props.children, uuid: this.uuid });
  }
  componentWillUpdate(nextProps) {
    sendPortal({ children: nextProps.children, uuid: this.uuid });
  }
  componentWillUnmount() {
    rmPortal(this.uuid);
  }
  render() {
    return null;
  }
}

const styleHelper = (isNull) => {
  if (isNull) {
    return {
      position: 'absolute',
      height: 0,
      width: 0,
    };
  }

  return {
    position: 'absolute',
    top: 0,
    right: 0,
    left: 0,
    bottom: 0,
  };
};

export class PortalOut extends Component { // eslint-disable-line
  constructor(props) {
    super(props);
    this.state = {
      portals: [
        // {
        //   uuid: 'string',
        //   children: 'ReactChildren',
        // },
      ],
    };

    mitter.on('portal_on_change', (uuidReactChildren) => {
      const portals = this.state.portals;
      const uuid = uuidReactChildren.uuid;
      const reactChildren = uuidReactChildren.children;

      if (portals.some(protal => protal.uuid === uuid)) {
        portals.forEach((protal) => {
          if (protal.uuid === uuid) {
            protal.children = reactChildren;
          }
        });
        this.setState({ portals });
      } else {
        portals.push(uuidReactChildren);
        this.setState({ portals });
      }
    });
    mitter.on('portal_rm', (uuid) => {
      const portals = this.state.portals;
      const foundIndex = portals.findIndex(portal => portal.uuid === uuid);
      portals.splice(foundIndex, 1);
      this.setState({ portals });
    });
  }

  render() {
    const isNull = this.state.portals.filter(portal => !!portal.children).length === 0;
    return (React.createElement(View,
      { style: styleHelper(isNull) },
      this.state.portals.map(item => item.children)
    ));
  }
}

I cannot found how to resolve it. Hope you can found something and tell me.
Really Hope.

does PortalProvider really need to use setState?

Hi,

I'm considering using this library for my React Native project, because the implementation looks really simple and straightforward.

However, upon reviewing the code, I noticed that PortalProvider uses state to store the current implementation for each portal name. What worries me is that changing the state usually triggers re-renders of everything that's under it. Considering that PortalProvider would usually way up in the application component tree, this could mean triggering re-renders of the whole application, i.e. things that are not at all involved in with the relevant WhitePortal or BlackPortal.

Would it make sense to store the current implementation as a local variable bound to the PortalProvider object itself? In other words:

  portalSet = (name, value) => {
    const emitter = this._emitter;
    this.implementations[name] = value
    emitter && emitter.emit(name)
  };

  portalGet = name => this.implementations[name] || null

My understanding is that the necessary renders would still happen because we have explicit forceUpdates in WhitePortal. Shouldn't that be enough?

v1.1.1 doesn't work with react-native

I upgraded from v1.0.2 to v1.1.1 and react-native v0.46.4 app failed with red screen and error message React is not defined. Downgraded to v1.0.2 and everything is working again. So I guess something is wrong with rollup build?

Would you accept a pull request?

Would you accept and publish a pull request so we could get rid of

Warning: componentWillMount has been renamed

deprecation warning.

Help: usage with react-native-video

Hi, I've been trying to use this with react-native-video, to keep video playing while allowing it to be rendered anywhere. When using it this way, playback is restarted every time a different WhitePortal is used.

Is it possible to achieve a smooth playback transition between portals somehow?

Thanks!

Deprecated Lifecycle Methods

These 3 specifically are deprecated as of React 17
componentWillMount
componentWillRecieveProps
componentWillUpdate

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.