What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-01-23 02:16:22
react onclick parameter
import React from 'react'; const ExampleComponent = () => { function sayHello(name) { alert(`hello, ${name}`); } return ( <button onClick={() => sayHello('James')}>Greet</button> ); } export default ExampleComponent; Add solution -
Javascript 2022-01-23 01:56:53
handling scrolling on react router transitions
import { useEffect } from 'react'; import { withRouter } from 'react-router-dom'; function ScrollToTop({ history }) { useEffect(() => { const unlisten = history.listen(() => { window.scrollTo(0, 0); }); return () => { u... Add solution -
Javascript 2022-01-22 20:36:39
get values form query params in next js
Consider the following page: pages/post/[pid].js: import { useRouter } from 'next/router' const Post = () => { const router = useRouter() const { pid } = router.query return <p>Post: {pid}</p> } export default Post https://stacko... Add solution -
Javascript 2022-01-22 20:31:11
immutability helper
import React, { Component } from "react"; import "./styles.css"; import update from "immutability-helper"; class App extends Component { state = { pizzas: { margherita: { toppings: ["tomato sauce&quo... Add solution -
Javascript 2022-01-22 15:55:45
how to use adminlte in reacts
import React, { Component } from 'react'; import AdminLTE, { Sidebar, Content, Row, Col, Box, Button } from 'adminlte-2-react'; const { Item } = Sidebar; class HelloWorld extends Component { state = {} render() { return (<Content title="... Add solution -
Javascript 2022-01-22 13:26:56
nextjs Access-Control-Allow-Origin
//npm i cors //# or //yarn add cors import Cors from 'cors' // Initializing the cors middleware const cors = Cors({ methods: ['GET', 'HEAD'], }) // Helper method to wait for a middleware to execute before continuing // And to throw an error when an ... Add solution -
Html 2022-01-22 09:10:13
vuejs import component
<template> <your-component></your-component> </template> <script> import YourComponent from '../components/YourComponent.vue' export default { components: { YourComponent // <=> YourComponent: 'YourComp... Add solution -
Javascript 2022-01-22 08:10:08
how to spot Error: Maximum update depth exceeded. in react
import React, { Component } from 'react'; import styled from 'styled-components'; class Item extends React.Component { constructor(props) { super(props); this.toggle= this.toggle.bind(this); this.state = { det... Add solution
Best helpers
Ranking is empty