I am working on a react native, and I want to know if there is a way to return two components that belong to the same function. I have the following code:
import React, { useState } from "react";
import { Text, View } from "react-native";
const SaveMessage = ({ FirstMassege }) =>{
return(
<Text>{FirstMassege}</Text>
)
}
export const StateContext = React.createContext(null);
const concatMessage = ({ children }) =>{
const [colorless, Setaddcolor] = React.useState([])
statecolor = {
color : [colorless, Setaddcolor]
}
return (
<View>
<SaveMessage title='primera parte del mensaje'/>
</View>
<StateContext.Provider value={statecolor}>{children}</StateContext.Provider>
);
}
As you can see, the first component that returns with the message is fine, however, when I want to include the StateContext in the return, it throws me a syntax error. I already tried adding a comma after the View tag. However this causes the component with the message to be replaced by the Context. How can i fix this?