Skip to content

Instantly share code, notes, and snippets.

@Paulius11
Last active June 4, 2020 10:32
Show Gist options
  • Save Paulius11/8c2c02f88a04a437960e43b6af331986 to your computer and use it in GitHub Desktop.
Save Paulius11/8c2c02f88a04a437960e43b6af331986 to your computer and use it in GitHub Desktop.
React snippets
# Elementu išpakavimas
{lists.map(list => <li>{list.projectName}</li>)}
# Funkcinio elemento hookai ir axios
const [lists, setprojects] = useState([]);
useEffect(() => {
axios
.get("http://localhost:9090/api/project")
.then(res => setprojects(res.data));
}, []);
#Componento kurimas
function App() {
const products = productsData.map(item => <Product key={item.id} map={item} /> )
return (
<ol>
{products}
</ol>
)
}
# React native custom button
<TouchableOpacity style={styles.customBtnBG} onPress={() => {}}>
<Text style={styles.customBtnText}>Button</Text>
</TouchableOpacity>
}
const styles = StyleSheet.create({
/* Here style the text of your button */
customBtnText: {
fontFamily: "nunito-regular",
fontSize: 25,
fontWeight: "400",
color: "#fff",
},
/* Here style the background of your button */
customBtnBG: {
backgroundColor: "darkcyan",
paddingHorizontal: 30,
paddingVertical: 5,
borderRadius: 1,
justifyContent: "center",
alignItems: "center",
marginBottom: 20,
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment