francoischalifour / medium-zoom

🔎🖼 A JavaScript library for zooming images like Medium
https://medium-zoom.francoischalifour.com
MIT License
3.59k stars 164 forks source link

A more "React-ish" example #17

Closed antoinechalifour closed 6 years ago

antoinechalifour commented 6 years ago

Hey there!

I feel like the React example does not feel "React-ish" enough as it is querying the DOM.

Here is how I would use it with React: https://codepen.io/antoinechalifour/pen/rGLRom

Great job!

francoischalifour commented 6 years ago

Hey!

You're right, I basically copied the vanilla JS into the componentDidMount() method. The reason for that is that I wanted to emulated an environment where you want to pull data from a Markdown file already containing the DOM elements. Essentially, I wanted the exact same demo as the javascript example.

I should probably rename this example react-markdown and create another react example. That said, I should definitely move the "journal" feature into the state.

I'll take some time to find a good use case to demo a more React-ish example as well as some other libraries/frameworks.

Cheers!