Giter Site home page Giter Site logo

Comments (6)

lucasferreira avatar lucasferreira commented on July 17, 2024 1

Hi @imouto2005

Now I get it. renderCustomContent was a contribution from other user to this lib, but I think it's easy to solve your problem.

I main render method you could change this:

render() {
    const { renderFlashMessageIcon, renderCustomContent, MessageComponent } = this.props;
    const { message, visibleValue } = this.state;

    const style = this.prop(message, "style");
    const textStyle = this.prop(message, "textStyle");
    ...

In this:

render() {
    const { renderFlashMessageIcon, MessageComponent } = this.props;
    const { message, visibleValue } = this.state;

    const style = this.prop(message, "style");
    const textStyle = this.prop(message, "textStyle");
    const renderCustomContent = this.prop(message, "renderCustomContent");
    ...

The this.prop method are made just to deal with when the props comes from message or come from the instance ;)

Could you try over there and tell if it works?

from react-native-flash-message.

lucasferreira avatar lucasferreira commented on July 17, 2024

Hi @imouto2005,

the renderCustomContent prop doens't receive a function, it receive only a React Node or Element, something like this:

renderCustomContent={<MyCustomEl />}

from react-native-flash-message.

imouto2005-zz avatar imouto2005-zz commented on July 17, 2024

Hi there,

Thanks for getting back to me. I mean that there is no renderCustomContent prop being passed into DefaultFlash as it is instead being passed inside the message prop. That's why the current code on line 228 {!!renderCustomContent && renderCustomContent()} doesn't display anything as renderCustomContent is null. I was only able to get my custom component to show up after changing it to {!!message.renderCustomContent && message.renderCustomContent()}.

from react-native-flash-message.

berman82312 avatar berman82312 commented on July 17, 2024

Hi, I ran into a similar issue recently on renderFlashMessageIcon when passing custom icon via the message object, which was passed to the showMessage function.

And thanks @lucasferreira, your solution in #51 (comment) solves the problem perfectly!

I changed

const { renderFlashMessageIcon, renderCustomContent, MessageComponent } = this.props;

into

const { renderCustomContent, MessageComponent } = this.props;

const renderFlashMessageIcon = this.prop(message, "renderFlashMessageIcon");

and solved the issue. 👍

from react-native-flash-message.

giacomocerquone avatar giacomocerquone commented on July 17, 2024

@lucasferreira could you implement that or do you prefer a PR? Personally it seems wrong to pass customContent inside the component instantiation instead of passing it to the showMessage function

from react-native-flash-message.

federicomiralles avatar federicomiralles commented on July 17, 2024

Hi @imouto2005

Now I get it. renderCustomContent was a contribution from other user to this lib, but I think it's easy to solve your problem.

I main render method you could change this:

render() {
    const { renderFlashMessageIcon, renderCustomContent, MessageComponent } = this.props;
    const { message, visibleValue } = this.state;

    const style = this.prop(message, "style");
    const textStyle = this.prop(message, "textStyle");
    ...

In this:

render() {
    const { renderFlashMessageIcon, MessageComponent } = this.props;
    const { message, visibleValue } = this.state;

    const style = this.prop(message, "style");
    const textStyle = this.prop(message, "textStyle");
    const renderCustomContent = this.prop(message, "renderCustomContent");
    ...

The this.prop method are made just to deal with when the props comes from message or come from the instance ;)

Could you try over there and tell if it works?

I can confirm it works as expected!

Personally I think this approach is more flexible than having it as part of FlashMessage component. Indeed passing the renderCustomContent as another message option makes it more customisable because allows to tailor the JSX to be rendered from anywhere when it's used to display messages globally.

@lucasferreira are you planning to release it any time soon?

BTW awesome work! Thanks!

Cheers,

Federico

from react-native-flash-message.

Related Issues (20)

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.