Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject React Component as content #107

Open
jojojoleeleelee opened this issue May 10, 2019 · 2 comments
Open

Inject React Component as content #107

jojojoleeleelee opened this issue May 10, 2019 · 2 comments

Comments

@jojojoleeleelee
Copy link

jojojoleeleelee commented May 10, 2019

Hello! I was wondering, is it possible to add a react component as the content?

I added the component inside the overlay like so -

 this.player.overlay({
      content: <SomeReactComponent />,
      align: 'bottom-left',
      overlays: [{
        start: 'play',
        end: 'end'
      }]
    });

and the SomeReactComponent is just a react component for a dynamic image renderer that looks like this

import like from './like.png';
import love from './love.png';
import neutral from './neutral.png';

class SomeReactComponent extends Component {
  getImage(pic) {
    const image = pic;
    return image;
  }

  render() {
    const pic = [love, like, neutral];
    
    return (
        <div>
          { sentimentsArray.map(sentiment =>
            <img src={this.getImage(pic)} style={{ width: '75%', height: '75%', objectFit: 'scale-down' }} />
          )}
        </div>
    );
  }
}

When i call this.player.overlay in my console, it says the overlays.options.content is a Symbol of React.element, however, I'm not getting anything as an overlay

Screen Shot 2019-05-10 at 1 38 26 PM

@dom-paul
Copy link

Hey, Where you able to figure how to achieve this? I am looking for something similar

@josewweee
Copy link

josewweee commented Mar 3, 2021

what i did was.
const plainHtml = SomeReactComponent();
and then.
this.player.overlay({
content: renderToStaticMarkup(plainHtml),
align: 'bottom-left',
overlays: [{
start: 'play',
end: 'end'
}]
});

the problem with this approach is that buttons inside the plainHtml wont work as expected. if you guys have a better way, let me know. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants