Skip to content

Instantly share code, notes, and snippets.

View Frodigo's full-sized avatar

Marcin Kwiatkowski Frodigo

View GitHub Profile
@Frodigo
Frodigo / jsx.js
Created October 26, 2021 18:16
JSX examples
export const App = () => {
return (
<main id="root">
<h1>Hello Folks!</h1>
<p>
Random question:
Is <strong>FC Barcelona</strong> win any match in the Champions League this season?
</p>
</main>
);
@Frodigo
Frodigo / index.js
Created September 8, 2021 06:45
state
// What's wrong with that code?
this.setState({
counter: this.state.counter + this.props.increment,
});
@Frodigo
Frodigo / index.js
Created September 8, 2021 06:39
Obj create
var Employee = {
company: 'xyz'
}
var emp1 = Object.create(Employee);
delete emp1.company
console.log(emp1.company);
@Frodigo
Frodigo / local-intercept-fragment.js
Created July 22, 2021 07:25
Targetables extample
(...)
ProductDetailComponent.insertAfterJSX('<section className={classes.title} />', `<${ShortDescription} productSku={productDetails.sku} />`)
@Frodigo
Frodigo / messages-context.js
Created June 23, 2021 07:09
React Context real example
import React, { createContext, useReducer } from 'react';
import {
    MessagesReducer,
    messagesInitialState,
    addMessage as addMessageAction,
@Frodigo
Frodigo / index.js
Last active June 23, 2021 06:19
React prop drilling example
import React, { useState } from "react";
export const Account = () => {
const [user, setUser] = useState({ name: "Marcin", country: "Poland" });
<AccountDetails user={user} setUser={setUser} />;
};
export const EditAccount = (props) => {
const { user, setUser } = props;
@Frodigo
Frodigo / guestForm.js
Created April 20, 2021 08:27
Re-factor Edit shipping to use Dialog [WIP]
import React, { Fragment } from 'react';
import { FormattedMessage, useIntl } from 'react-intl';
import { Form } from 'informed';
import { func, shape, string, arrayOf, number } from 'prop-types';
import { useGuestForm } from '@magento/peregrine/lib/talons/CheckoutPage/ShippingInformation/AddressForm/useGuestForm';
import { mergeClasses } from '../../../../classify';
import { isRequired } from '../../../../util/formValidators';
import Button from '../../../Button';
import Country from '../../../Country';
import React from 'react';
import { render, getByText } from '@testing-library/react';
import ErrorMessage from '../ErrorMessage';
test('ErrorMessage renders correctly', () => {
    const { container } = render(
@Frodigo
Frodigo / local-intercept.js
Last active March 25, 2021 07:52
PWA Studio local intercept
const { Targetables } = require('@magento/pwa-buildpack');
module.exports = targets => {
const targetables = Targetables.using(targets);
const ProductFullDetailComponent = targetables.reactComponent(
'@magento/venia-ui/lib/components/ProductFullDetail/productFullDetail.js'
);
ProductFullDetailComponent.insertBeforeJSX('<Button type="submit" />', '<span>Hello World! </span>');
@Frodigo
Frodigo / bash.sh
Created March 24, 2021 16:58
PWA Studio extending Storefront example
$ yarn create @magento/pwa
$ cd <project_dir>
$ yarn run buildpack create-custom-origin
$ yarn run watch