Coder Social home page Coder Social logo

use-latest's Introduction

use-latest

A React helper hook for storing latest value in ref object (updated in useEffect's callback).

use-latest's People

Contributors

andarist avatar jacobbuck avatar rebelliard avatar mino-txa avatar tu4mo avatar

Stargazers

Fog3211 avatar Andrew Smith avatar Ernst Salzmann avatar Alex Carpenter avatar Robson William avatar  avatar  avatar Yevgenii Mikhnytskyi avatar chwan avatar Asaf Katz avatar Muhammad Farid Zia avatar Mo avatar Mikey Stengel avatar  avatar Sébastien Lorber avatar Andrejs Agejevs avatar  avatar

Watchers

James Cloos avatar  avatar Mikey Stengel avatar

use-latest's Issues

React import style causes issues with build

I'm importing use-latest through react-textarea-autosize in a React library that gets built with rollup. The importing package (pkg-a) works and builds fine but packages that import that package (pkg-b) are unable to run and crash with the error:

TypeError: Cannot read property 'default' of undefined

> 10 |  */"production"!==process.env.NODE_ENV&&function(){var e=t,n=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler") [...]
     |                                                          ^

After adding react-textarea-autosize, the beginning of the built dist file changes from:

import e,{Component as t}from"react";

to:

import*as e from"react";import t,{Component as n,useLayoutEffect as r,useEffect as o,useRef as i,useCallback as a,forwardRef as s,createElement as l}from"react";

I've narrowed the issue down to this package (use-latest), and specifically the React import line:

import * as React from 'react'

The issue is resolved by changing the line to either:

import React from 'react'

or:

import { useRef } from 'react'

I believe the latter change is more in the style of your packages.

I will submit a PR shortly.

LICENSE file

Hello 🙂

Can you please add a LICENSE file to this repository?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.