Feliz.Plotly icon indicating copy to clipboard operation
Feliz.Plotly copied to clipboard

open Feliz.Plotly overwrites built-in "box" function

Open mfrawley opened this issue 3 years ago • 3 comments

Description

The "box" function exposed by Feliz.Plotly clobbers the built-in F# box function in F#. One needs it in order to box dependencies when using Feliz when creating stateful components. Opening this library makes the code much easier to read..Perhaps there is an easy resolution?

Steps to reproduce

  1. Open Feliz.Plotly
  2. Try something like React.useEffect(loadData >> Async.StartImmediate, [| (box state.startDate) |])

Expected behavior

Opening a library should probably overwrite any core language functions.

mfrawley avatar Apr 27 '21 13:04 mfrawley

I managed to find the namespace and using the fully qualified name for box it works i.e. Microsoft.FSharp.Core.Operators.box but needless to say this doesn't feel less hacky.

mfrawley avatar Apr 27 '21 13:04 mfrawley

Hi @mfrawley,

Yeah I think I agree, I'll get the API modified to rename box to box'. In the meantime you can also do state.startDate :> obj instead of boxing.

Shmew avatar May 01 '21 21:05 Shmew

As a more elegant temporary fix, you can override box back right after opening Feliz.Plotly.

open Feliz.Plotly
// Feliz.Plotly shadows `box`: https://github.com/Shmew/Feliz.Plotly/issues/25
let box = Microsoft.FSharp.Core.Operators.box

fahrenq avatar Oct 21 '22 11:10 fahrenq