statsig-io / react-sdk

An SDK for using Statsig Feature Management and Experimentation platform in React js clients
ISC License
6 stars 6 forks source link

type mismatch initializeValues #4

Closed jonsan-ng closed 2 years ago

jonsan-ng commented 2 years ago

The statsig-node statsig. getClientInitializeResponse returns Record<string, unknown> | null whereas the consumer StatSigSynchronousProvider is expecting Record<string, unknown>

tore-statsig commented 2 years ago

Being discussed elsewhere, but was intentional to force consumers of the API handle an edge case where their server SDK is initialized but has not fetched values from Statsig servers yet.

you can simply use:

initializeValues={statsig.getClientInitializeResponse(user) ?? {}}

To handle this case if you don't want to handle it differently.

tore-statsig commented 2 years ago

Closing as this isn't a true issue - the type mismatch was intentional and there are multiple ways to handle this case. We will consider allowing a nullable initializeValues in the future, but this is not a blocking issue