Comments (6)
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.
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.
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.
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.
@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.
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 frommessage
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)
- Does not render only on IOS HOT 3
- Not support iPhone 14 HOT 11
- Does not run on a CASIO Handheld running Android 8 HOT 4
- Show Toast Message always appears behind the modal in iOS when it is open using react-navigation 6.x HOT 13
- Flash message not shown on Android 9 (Sony Xperia Z1) HOT 5
- Invalid prop `icon` supplied to `FlashMessage`, expected one of type [string, object]. HOT 1
- Android cutoff HOT 5
- Warning: Failed prop type: The prop `message.message` is marked as required in `ForwardRef`, but its value is `undefined`.
- MessageOptions and MessageComponentProps interfaces are incorrect HOT 2
- How to test this component with RNTL? HOT 6
- Updating icon props to allow JSX.Element callback HOT 5
- custom icon not working
- Không thể xoá paddingTop HOT 1
- Try it out not working - Error on Snack
- FEATURE REQUEST: Persistent FlashMessage HOT 4
- Message disappers quickly in iOS
- onPress not triggered with TouchableWithoutFeedback - Pressable works
- Unable to show custom icon in the toast HOT 1
- closing a modal window by moving up
- Support for dynamic island on iOS? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-flash-message.