I’m using Awesome Alert for customize alert but I would like to apply it in functional component environment. This is my design
And this is my code
<AwesomeAlert
show={true}
showProgress={false}
title="AwesomeAlert"
message="I have a message for you!"
closeOnTouchOutside={false}
closeOnHardwareBackPress={false}
showCancelButton={true}
showConfirmButton={true}
cancelText="Reject"
confirmText="Approve"
confirmButtonColor="#AEDEF4"
cancelButtonColor="#DD6B55"
onCancelPressed={() => {
console.log("Reject")
}}
onConfirmPressed={() => {
console.log("Approve")
}}
/>
My question is, is Awesome Alert can only be applied in Class component? How am I able to implement it in Functional Component like the original Alert React Native?
2
Answers
You can use
AwesomeAlert
inside a functional component as you would inside a class component’srender()
function; any React component that can be rendered from a class component can also be rendered from a functional component.Just put it inside your
return
part of your functional component and it will workFor Example like this: