million icon indicating copy to clipboard operation
million copied to clipboard

bug: block doesn't work correctly

Open gigasource opened this issue 1 year ago • 1 comments

Describe the bug A clear and concise description of what the bug is.

To Reproduce Cell

import {Item} from "@/stories/Cell/CellForm.tsx";
import {useState} from "react";
import {block} from "million/react";

interface CellProps {
	item: Item
}

export const Cell = block(({item}: CellProps) => {
	const [active, setActive] = useState<boolean>(false);
	function onItemChange() {
		setActive(true);
		console.log('onItemChange', item.name);
	}

	return <div className={`border-[1px] h-full ${active ? 'border-amber-500' : 'border-[#EEEEEE]'}`}
																onPointerDown={() => onItemChange()}>
		<p>Cell</p>
		<p>{item.name} {item.price}</p>
	</div>
})

Cell.stories.tsx

import {Cell} from "./Cell.tsx";
import {Item} from "@/stories/Cell/CellForm.tsx";

export default {
	title: 'Example/Cell',
}

const item1 : Item = {name: 'A', price: 10};
const item2 : Item = {name: 'B', price: 10};
const item3 : Item = {name: 'C, price: 10};

export const CellEx0 = () => {
	return <div className={'flex h-[200px] gap-[10px]'}>
		<div className={'flex-1 flex-col flex gap-[10px]'}>
			<Cell item={item1}/>
			<Cell item={item2}/>
			<Cell item={item3}/>
		</div>
	</div>
}

When i click item A, then C , log show: onItemChange A Without block then it works correctly

Expected behavior A clear and concise description of what you expected to happen.

Screenshots image

Device (please complete the following information):

  • OS [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

gigasource avatar Jun 20 '23 16:06 gigasource

Hey @gigasource, are you by chance getting any errors or something?? 👀👀👀

tobySolutions avatar Jun 20 '23 21:06 tobySolutions

Fixed in v2.4.8-beta.2!

aidenybai avatar Jun 21 '23 07:06 aidenybai