NirKaufman

Greater New York City Area ยท nirkaufman@gmail.com

Web developer. Community enthusiast. Organizer of meetups. International public speaker.
Trainer. Author of books. Google developer expert in web technologies.
When I'm not coding I make music, and vegan food.


Upcoming Talks


Upcoming Workshops


Snippets

Make the entire document editable.

Controls whether the entire document is editable. Valid values are "on" and "off"
document.designMode = "on" || "off";
Click here to learn more

Destructuring arrays as objects

Sort unique numbers and destruct to find the highest and lowest values in one line of code.

    const numbers = [1,2,20,3,55,6,7,8,2,3,72,50];
    const {0:highest, length, [length - 1]:lowest} = Array.from(new Set(numbers)).sort( (a, b) => a - b );
    // highest -> 1, lowest -> 72
    
Click here to learn more

Get creative with React portals.

Create a portal to another window with react

    function WindowPortal({ children }) {
      const [externalWindow, setExternalWindow] = useState(null);

      useEffect(() => {
        const newWindow = window.open("", "", "width=600,height=400");
        setExternalWindow(newWindow);
        return () => newWindow.close();
      }, []);
    
      if (!externalWindow) return null;
      return ReactDOM.createPortal(children, externalWindow.document.body);
    }
    
Click here to learn more