Snippets Collections
 <script>
    $("#file").change(function() {
      filename = this.files[0].name;
      $('.filename').text(filename);
    });
  </script>
 <script>
    $("#file").change(function() {
      filename = this.files[0].name;
      $('.filename').text(filename);
    });
  </script>
function MyComponents() {
	const { canvas } = useContext(CanvasCTX);
    if (canvas) {
    	console.log(canvas.getActiveObject())
    }
    
    return <div>I am a child component</div>
    
}
function MyComponents() {
	const { canvas } = useContext(CanvasCTX);
    if (canvas) {
    	console.log(canvas.getActiveObject())
    }
    
    return <div>I am a child component</div>
    
}
// This will not work in React 16 and earlier
const CreateTodo = () => {
  const mutation = useMutation({ mutationFn: event => {
    event.preventDefault()
    return fetch('/api', new FormData(event.target))
  }})


  return <form onSubmit={mutation.mutate}>...</form>
}


// This will work
const CreateTodo = () => {
  const mutation = useMutation({ mutationFn: formData => {
    return fetch('/api', formData)
  }})
  const onSubmit = event => {
    event.preventDefault()
    mutation.mutate(new FormData(event.target))
  }


  return <form onSubmit={onSubmit}>...</form>
}
function Todos() {
  const [filter, setFilter] = React.useState('')


  const { data } = useQuery(
    ['todos', filter],
    () => fetchTodos(filter),
    {
      // ⬇️ disabled as long as the filter is empty
      enabled: !!filter
    }
  )


  return (
      <div>
        // 🚀 applying the filter will enable and execute the query
        <FiltersForm onApply={setFilter} />
        {data && <TodosTable data={data}} />
      </div>
  )
}
star

Tue Dec 20 2022 13:11:37 GMT+0000 (Coordinated Universal Time)

#tsx
star

Tue Dec 20 2022 13:11:35 GMT+0000 (Coordinated Universal Time)

#tsx
star

Tue Dec 13 2022 08:44:45 GMT+0000 (Coordinated Universal Time) https://www.devtip.co/using-fabric-js-with-react/

#tsx
star

Tue Dec 13 2022 08:44:19 GMT+0000 (Coordinated Universal Time) https://www.devtip.co/using-fabric-js-with-react/

#tsx
star

Mon Nov 28 2022 13:14:14 GMT+0000 (Coordinated Universal Time) https://tanstack.com/query/v4/docs/guides/mutations

#tsx
star

Thu Sep 15 2022 14:12:53 GMT+0000 (Coordinated Universal Time) https://tanstack.com/query/v4/docs/guides/disabling-queries#lazy-queries

#tsx #react.js #usequery

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension